I tell you what is wrong with #HTML5 templates

Oscar Brito



I really don't like HTML5 templates. Where is the templating engine separation between data and markup?

Template Example:


<template id="mytemplate">
<div>Var=<span>0</span></div>
</template>

Template Rendering:


var content = document.querySelector('template').content;
var span = content.querySelector('span');

//THIS IS REALLY WRONG
span.textContent = parseInt(span.textContent) + 1;

document.querySelector('#container').appendChild(content.cloneNode(true));

Conclusion:

  • It really doesn't help much without interpolation and templating logic (like Mustache.js)
  • It really just provides an hidden element in the DOM.
  • I will continue to use things like Mustache.js or Swig.


LINK:
http://www.html5rocks.com/en/tutorials/webcomponents/template/
https://github.com/paularmstrong/swig
https://github.com/janl/mustache.js/



Visit www.divhide.com for more informations, contacts and news about Web Development.
See other blog posts at blog.divhide.com.



Divhide purpose is to follow the HTML5 movement and contribute with applications which prove the quality of technology.


Feel free to contact divhide.