Thanks Jeppe, that looks like what I need.

I'm having trouble following your example though, what are res,
filteredResult, lc, etc?  My code looks like this right now:

def render( xhtml: NodeSeq ): NodeSeq {
  items.flatMap( f =>
      bind("item", xhtml,
        "name" -> item.name
      )
}

so presumably I'd need to add to that to bind an attribute called
value:

def render( xhtml: NodeSeq ): NodeSeq {
  items.flatMap( f =>
      bind("item", xhtml,
         "name" -> item.name,
         AttrBindParam("value", item.value)
      )
}


>                  bind("values", in,
>                       BindNumber("tco", 
> res.filteredResult(lc).avgTCO(segment)),
>                       
> AttrBindParam("rankClass",Text(rankClass(res.rankBySegment(lc, segment))), 
> "class")
>                  )


On Nov 19, 5:46 pm, Jeppe Nejsum Madsen <[email protected]> wrote:
> Alex Black <[email protected]> writes:
> > For example, if my html template looks like this:
>
> > <lift:surround with="default" at="content">
> >            <h2>foobar</h2>
> >                 <lift:MySnippet.render>
> >                 <img src="dummy"/>
> >                 </lift:MySnippet.render>
> > </lift:surround>
>
> > In my snippet I'd like to replace "dummy" (in img src) with a real
> > value.  I'm sure there are other ways to output img tags with
> > attribute values, but I'm specifically interested in this general
> > case: writing the presentation in the template, and filling in the
> > attribute value from code.
>
> Use AttrBindParam and prefix the attribute with the bind point
>
> Template:
>       <td values:rankClass=""><values:tco/></td>
>
> Code:
>                  bind("values", in,
>                       BindNumber("tco", 
> res.filteredResult(lc).avgTCO(segment)),
>                       
> AttrBindParam("rankClass",Text(rankClass(res.rankBySegment(lc, segment))), 
> "class")
>                  )
>
> This will render
>  <td class="something">42</td>
>
> /Jeppe

--

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=.


Reply via email to