Html5 and XHTML are different

Skip to first unread message

David Pollak

May 21, 2011, 1:27:56 PM5/21/11
to liftweb
Please read this message and the following link before posting any questions about snippets not properly being invoked:

The XHTML parser (the traditional Lift parser) and the Html5 parser are different.  Specifically:
  • The Html5 parser converts all element labels and attribute names to lower case.  This means if you are trying to invoke a snippet named FooBar via <lift:FooBar/> it will not work.  Why?  First, the Html5 parser doesn't deal with self-closed tags, so <lift:FooBar/> is silently discarded.  So, next we try <lift:FooBar></lift:FooBar>.  But the Html5 parser converts it to <lift:foobar></lift:foobar> and the FooBar class is not found.  If you're using the Html5 parser, please, please, please use the designer friendly invocation mechanisms *exclusively*.  This means that <div class="lift:FooBar">stuff</div> is the best way to go with the Html5 parser.
  • The Html5 parser converts attribute names to lower case.  This means that snippets that are looking for camel-case attribute names will not find the attributes.  Yes, this is the same thing I said in the above paragraph, but I'm saying it again because this seems to have led to a lot of confusion on the Lift list.  So, if you're using the Html5 parser, use designer friendly snippet invocation.
  • The XHTML parser is unforgiving about malformed XHTML.  You *must* have well formed XML as input if you're using the XHTML parser.  This means all tags *must* have a closing tag.  XHTML and some JavaScript libraries do not work well together as the XHTML spec does not allow the write() method in JavaScript and browsers enforce this.  If you're using Google Maps or some other JavaScript libraries, it's best not to use XHTML.
So, please read this *before* posting about snippet invocation errors, JavaScript errors (especially in Google supplied JavaScript libraries), or attributes not getting picked up in snippets.  Yes, a lot of old example code does not work well with the Html5 templates.  We've done our best to make the transition to Html5 and Designer Friendly as easy as possible, but sometimes the differences, well, make a difference.



Lift, the simply functional web framework
Reply all
Reply to author
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages