D3.js
templating test based on my previous solution of John Berryman’s attempt.
The HTMLTemplateElement
is currently supported in Chrome, Firefox and Opera (15+) for now. See Eric Bidelman HTMLTemplateElement tuturial
I change the idea of use HTMLTemplateElement.content
because is only supported by 3 browsers . I’m using HTMLElement.innerHTML
to read the template content and DOMParser()
to inject the result into the DOM.
To hide the content of <template> (HTMLUnknownElement)
on other browsers (Safari, IE, etc) I add a CSS rule with display:none
. On browsers that support HTMLTemplateElement
the <script>
isn’t fired when the browser parse the document, but is different on HTMLUnknownElement
s. If someone know how to break the script execution on HTMLUnknownElement
s please send me a tweet @baldpower
TODOs:
Handlebars.js
and Hogan.js
.