bind("alsoKnownAs", in, "list" -> { (ns: NodeSeq) => bind("list", ns,
"label" -> ... ) })
-Ross
On Dec 23, 2009, at 3:59 PM, Alex Black wrote:
> I've got this xhtml in my template:
>
> <lift:Compare.loserAlsoKnownAs>
> Also known as:
> <ul>
> <alsoKnownAs:list>
> <li><list:label /></li>
> </alsoKnownAs:list>
> </ul>
> </lift:Compare.loserAlsoKnownAs>
>
> with this snippet code:
>
> def alsoKnownAs( xhtml: NodeSeq, product: Product): NodeSeq = {
> def list( xhtml: NodeSeq, product: Product): NodeSeq = {
> product
> .alternateLabels
> .flatMap( l =>
> bind("list", xhtml,
> "label" -> l
> )
> )
> }
>
> product.alternateLabels match {
> // Remove the entire block (including title if there are no
> alternate labels)
> case Nil => Nil
> case _ => bind("alsoKnownAs", xhtml, "list" -> list
> (chooseTemplate("alsoKnownAs","list", xhtml), product))
> }
> }
>
> This works well:
> - The entire XHTML is removed if there are no alternateLabels
> - If there are alternateLabels, the "Also known as:" text is not
> repeated, just the LI elements in the list
>
> However, in my bind call:
>
> case _ => bind("alsoKnownAs", xhtml, "list" -> list
> (chooseTemplate("alsoKnownAs","list", xhtml), product))
>
> I specified alsoKnownAs:list twice, it feels a bit redundant... The
> intent of the code is: find the thing called alsoKnownAs:list, grab
> the xhtml below it, pass it into the list function, and replace its
> value with the output of list.
>
> Is there some trick I'm missing here to avoid specifying things twice?
>
> Just curious - the solution is pretty elegant as is.
>
> - 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.