I'm using bind()
to replace XML elements in my template with String values, like so:
bind("foo", nodes, "bar" -> "My Content")
When I use a self-closing element in my template, like so:
What I want to see is <foo:bar />, and everything after it.
I'll occasionally get this:
What I want to see is My Content
and not this:
What I want to see is My Content, and everything after it.
But when I change the template to use a non-self-closing empty element:
What I want to see is <foo:bar></foo:bar, and everything after it.
I'll always get the fully rendered content.
I haven't yet been able to figure out what triggers the erroneous behaviour for self-closing tags.
Is this merely a Lift bug, or is there some reason for this to occur?
The problem is with the HTML parser that Lift uses. For most tags, it doesn't recognize the self close and will assume that the content after it is content within the tag (hence it gets stripped). The same problem will exist if you attempt to use <div />
or similar tags in combination with CSS selectors. I'm not sure it is a bug per se, as that seems to be the expected behavior in HTML5 (at least according to the accepted answer's last bullet point).