I have trouble finding out why my content is not being properly replaced. The only thing that is working in doLine is the addId stuff. None of the rest is being selected nor replaced. Can anyone say what am I missing?
Thanks in advance.
D.
<lift:comet type="articleUpdater">
<ul id="articles">
<div class="article">
<li class="entry">
<a href="#" class="link"></a> : <span id="category">Category</span>
</li>
</div>
</ul>
</lift:comet>
def render = "#articles *" #> lines _
private def lines(xml: NodeSeq): NodeSeq = {
bindLine = xml
for {
m <- articles.reverse
node <- doLine(m)
} yield node
}
private def doLine(m: Article): NodeSeq = {
( "*" #> addId(bindLine, m.id.is.toString) &
".link *" #> m.title.is &
".link [href]" #> "/article/%s".format(m.id.is) &
"#category" #> m.category.is)(bindLine)
}
private def addId(in: NodeSeq, id: String): NodeSeq = in map {
case e: Elem => e % ("id" -> id)
case x => x
}
Thanks,
D.
--- On Mon, 4/16/12, Antonio Salazar Cardozo wrote:
>Lift's transforms don't apply twice to the elements when joined by &.
>You'll want to change the & after the "*" selector to andThen instead,
>which is a higher-level function combinator provided by Scala. It's slower
>(transforms joined by & are run at the same time, while andThen runs the
>function to the left and then the one to the right on its results), but in
>this case necessary.
>Thanks,
>Antonio