Search code examples
xmlscalalift

Variable in attribute value of XML-literal


I'm working with LiftWeb, XML and the bind method.

This works:

scala> val id = "test"                    
id: java.lang.String = test

scala> <a href={id}>link</a>              
res4: scala.xml.Elem = <a href="test">link</a>

but what if I want <a href="page?param=test">link</a>?

This doesn't work:

scala> <a href="page?param={id}">link</a>   
res5: scala.xml.Elem = <a href="page?param={id}">link</a>

Solution

  • You put the whole thing inside the brackets:

    <a href={ "page?param=" + id }>link</a>