// this is a mail for suggesting adding internal template engine into html5
Hi Sir:
I'm a php developer who sometimes touch javascript. I think there might be requirements for adding internal template system into modern browser.
Normally js lib would like to do this (for example in backbone):
<script type="text/template" id="...">
...
</script>
Obviously we need a common tag for that purpose when comparing to script/css links:
- script with
srcattribute can link to those common javascript files - link with
hrefattribute can link to those common css styles
What about common html templates? We could define the same thing for this:
// index.html
<tpl local id="tpl-foo">...</tpl>
// tpls.html
<tpl global id="tpl-bar">...</tpl>
The differences between use <script> and <tpl> are as folloing:
- global templates will be cached just like cookie/localStorage
- they can be obtained by the template engine,
document.getTemplateById('tpl-foo') - they are hidden doms (so, there's no need extra step of parsing from string to dom -- like angularJs)
- also support json as arguments.
document.getTemplateById('tpl-foo').with(...json data...)
So what about this?
Thanks.
Yarco
Here are the links related to those stuff:
And for discussion, we should send mail to: public-html-comments at w3.org