Jquery.tmpl templates violate XHTML validation

I have a document with the following doctype type:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru">

Templates are declared as follows:

 <script id="tmpl-periods-options" type="text/x-jquery-tmpl">   
        {{each plans_array}} 
            <label><input type="radio" value="${$value.id}" name="pf-periods" {{if $value.selected}}checked="checked" {{/if}} />${$value.title}</label>
        {{/each}}           
    </script>   

http://validator.w3.org/ shows me errors in the html code that is declared inside the tag <script>.

Is there any solution?

+3
source share
1 answer

Normal JavaScript methods do not work, because it is not JavaScript; just wrapping the template in //<![CDATA[ ... //]]>or //<!-- ... //-->just causing the worst problems.

As stated in this blog post , it seems that the best options are either using HTML 5, or placing the template in an external file and including that.

$(document).ready(function() {
    $.get('template.html', function(content) {
        $.template('template name', content);
    });
});
+3
source

All Articles