Thanks Derek. Familiarity with the APIs is one of the tricks when moving to a new language I guess.
This worked for me, but I have a follow-on issue.
Just as a background I am rendering search results which are provided as XML. Here's my binding code:
result => bind("entry", chooseTemplate("listings", "listing", xhtml),
"title" -> <a href={result.url}>{Unparsed(result.title)}</a>,
"description" -> Unparsed(result.description),
"link" -> Text(result.url))
})
This fails to compile as the Unparsed in the description line is not a valid parameter for the bind function. (I'm not sure why, it's just a fancy Node like any other right?) The exact error is:
overloaded method value bind with alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) => scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute) => scala.xml.MetaData],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)scala.xml.NodeSeq <and> (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)scala.xml.NodeSeq cannot be applied to (java.lang.String,scala.xml.NodeSeq,net.liftweb.util.Helpers.TheBindParam,(String, scala.xml.Unparsed),net.liftweb.util.Helpers.TheBindParam)
If I change that line to
"description" -> Text(Unparsed(result.description)) it compiles, but the Text constructor will re-escape so I'm back to square one.
If I change the line to "description" ->
<span>{Unparsed(result.description)}</span>, it compiles but I have an unwanted span tag and worse ... if result.description is not well formed XML my page will fail to render! Firefox complains of an XML Parsing Error. The description field has an unmatched <br> tag (literally <br>) in the middle of it to force it onto two lines.
So my first question is, how can I avoid the extra <span> tag?
Secondly, can I render (!X)HTML via Lift?
Thanks
Jeremy
--
Jeremy Mawson
Senior Developer | Online Directories
Sensis Pty Ltd
222 Lonsdale St
Melbourne 3000
E:
jeremy...@sensis.com.au