This has probably come up previously, but I couldn't find anything
even though I think a couple of days ago I read about something
similar:

I want to do a snippet that behaves similarly to JSTL-s forEach tag.
Not exactly the same, but the idea is that it gets some list of model
objects, then goes through it element by element and processes the
input NodeSeq for each element. What I came up with is this:

  def foreach(in: NodeSeq) = {
    val msgs = somehowGetAListOfModelObjects();
    msgs.flatMap { msg =>
      // set the current object (CurrentMessage is a ThreadLocal)
      CurrentMessage.set(msg)
      // process the contents, with the current object in scope
      S.session.get.processSurroundAndInclude("", in)
    }
  }

And it's called like this:
        <lift:blabla.foreach>
                <lift:embed what="message.html" />
        </lift:blabla.foreach>


Is there a more correct solution to this?

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to