net.liftweb.util.BindHelpers
BindParam that computes an optional new attribute value based on the current attribute value. Returning Empty in the transform function will result in the Attribute being omitted. For example, given the following markup:
<lift:AttrBinds> <div test:x="foo"> <div test:y="foo"> </lift:AttrBinds>
The following snippet:
import scala.xml._ class AttrBinds { def render(xhtml : NodeSeq) : NodeSeq = BindHelpers.bind("test", xhtml, FuncAttrBoxBindParam("x", { ns : NodeSeq => Full(Text(ns.text.toUpperCase + "X"))}, ("lift","calcId")), FuncAttrBoxBindParam("y", { ns : NodeSeq => if (ns.text.length > 10) { Full(Text(ns.text.length + "Y")) } else { Empty }, ("lift","calcId")))
produces this markup:
<div lift:calcId="FOOX" /> <div />
The name to bind against
The new attribute label
BindParam that computes an optional new attribute value based on the current attribute value. Returning Empty in the transform function will result in the Attribute being omitted. For example, given the following markup:
The following snippet:
import scala.xml._ class AttrBinds { def render(xhtml : NodeSeq) : NodeSeq = BindHelpers.bind("test", xhtml, FuncAttrBoxBindParam("x", { ns : NodeSeq => Full(Text(ns.text.toUpperCase + "X"))}, ("lift","calcId")), FuncAttrBoxBindParam("y", { ns : NodeSeq => if (ns.text.length > 10) { Full(Text(ns.text.length + "Y")) } else { Empty }, ("lift","calcId")))produces this markup: