How to make Resig's micro-templates XHTML compliant?

Posted by mshelv on Stack Overflow See other posts from Stack Overflow or by mshelv
Published on 2009-06-25T14:57:37Z Indexed on 2010/04/12 1:53 UTC
Read the original article Hit count: 379

Filed under:
|
|

Hello,

I have been experimenting with John Resig's micro-template, which works great. However, the mark-up will not pass the XHTML 1.0 Transitional validation test. (Among other things, id attributes yield errors.)

Replacing tags identifiers <, > with [[,]], passes validation. Thus, I created a js script which at load time (jQuery document ready) converts the square brackets back to regular markers. This works fine in FF, but not in IE, Chrome, etc.

Scripts embedded within CDATA tags validate as well.

Question: Is there a way to insert micro-template in a script and still pass XHTML validation? My idea was to remove the CDATA tags once the page has been loaded. But there are probably smarter ways. (Note: I'd prefer not to inject HTML via js since the mark-up will be difficult to maintain.)

PS: I looked at other js templates, but they are either not XHTML compliant or too bulky.

TIA for any hints.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about template