I've been using <script type=”text/html“> to hold bits of HTML I want to quilt together client-side.
I build all my templates in HTML, and then store all the different content to populate the templates in script tags. I can then use JavaScript to swap it out, and even hide/reveal unused templates.
It's 100% valid though, handlebars are not valid HTML, at least not until processed and rendered.
The <template> tag is meant for that - not only are the contents inert, but they're also exempt from HTML5's special processing rules, so you can eg. put them in tables without having them foster parented.
The big issue right now is IE support, but most browsers are coming along with it:
I build all my templates in HTML, and then store all the different content to populate the templates in script tags. I can then use JavaScript to swap it out, and even hide/reveal unused templates.
It's 100% valid though, handlebars are not valid HTML, at least not until processed and rendered.