S.attr gives you attributes of the current snippet calling tag, e.g.
class Item extends DispatchSnippet {
val dispatch: DispatchIt = {
case "points" => points
}
def points(ns: NodeSeq): NodeSeq = {
val points = S.attr("item") match {
case Full("first") => loadFirstListOfPoints()
case Full("second") => loadSecondListOfPoints()
case _ => error("missing item attribute or has incorrect
value")
}
bind(...)
}
}
-Ross
On Dec 23, 2009, at 4:07 PM, Alex Black wrote:
> I've got some xhtml blocks in one of my templates that are basically
> identical, and I'd like to avoid the duplication, by either writing
> the block once in my template and using a snippet to write it out
> twice (with different values) or put it in its own template.
>
> <h1>Items</h1>
>
> <h2>First</h2>
> <ul>
> <lift:Item.firstPoints>
> <li><point:name />
> </lift:Item.firstPoints>
> </ul>
> <lift:item.firstPicture />
>
> <h2>Second</h2>
> <ul>
> <lift:Item.secondPoints>
> <li><point:name />
> </lift:Item.secondPoints>
> </ul>
> <lift:item.secondPicture />
>
> My question is: If I write this block once, and surround it in a
> snippet which emits it twice, how can the snippet parameterize the
> nested snippet calls?
>
> I realize I could bind the entire block with one snippet call, but
> because my real blocks are big and complex I'd like to keep the many
> snippet calls per block.
>
> So, more specifically, how can i write <lift:Item.secondPoints> and
> <lift:item.firstPoints> more like this: <lift:item.points
> item="@curItem">
>
> thx
>
> - Alex
>
> --
>
> 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
> .
>
>
--
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.