D3.js
templating test based on my previous solution of John Berryman's attempt.
ICahnHaz.js
uses <script></script>
and I preffer the idea of Eric Bidelman.
The <template>
element is currently supported in Chrome, Firefox and Opera (15+)for now.
Because the use of innerHTML
run-time string parsing of user-supplied data can easily lead to XSS vulnerabilities and isn't supported by SVGElement
, I use now XMLSerializer()
and DOMParser()
to inject the templates into the DOM.
The callTemplate
function uses querySelector
and isn't limitted to Mustache
.
TODOs:
Handlebars.js
and Hogan.js
.Modified http://d3js.org/d3.v2.min.js to a secure url
Modified http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.7.2/mustache.min.js to a secure url
https://d3js.org/d3.v2.min.js
https://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.7.2/mustache.min.js