On Mar 6, 10:57 am, Marius <[email protected]> wrote:
> Actually thinking more into it there is a good reason for -%> to not
> have a (NodeSeq) => NodeSeq support. -%> means that it preserves the
> attributes specified in the template to the resulting node.But having
> a bunch of attributes we can't apply them to a NodeSeq because aa
> NodeSeq means a sequence of Nodes with no commn parent so we can;t
> determine to which node we'd apply those attributes. AFAIK only an
> Elem can have attributes.


Why not just map the attributes over all of the top level elements in
the nodeseq?

scala> val a = <p class="blah">template</p>.attributes
a: scala.xml.MetaData =  class="blah"

scala> val s:NodeSeq = <p>first para</p><p>second para <b>with nested
stuff</b></p>
s: scala.xml.NodeSeq = <p>first para</p><p>second para <b>with nested
stuff</b></p>

scala> val result: NodeSeq = s.map( { case e: Elem => e % a; case n =>
n } )
result: scala.xml.NodeSeq = <p class="blah">first para</p><p
class="blah">second para <b>with nested stuff</b></p>

This is semantically just fine with regard to, say, an attribute of
class.  Its the designer's own fault if they put in an attribute of id
into a tag that may get repeated.

As I recall, the current behavior of -%> leads to some annoying
inconsistencies compared to ->, eg not being able to just return
NodeSeq.Empty if you want to get rid of a bound tag.

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