Playground
Based on the excellent
DoT.js
website
Template
Hi <% console.log("Hope you like Eta!"); %> <%= it.htmlstuff %> <% for (var key in it.obj) { %> Value: <%= it.obj[key] %>, Key: <%= key %> <% if (key === 'thirdchild') { %> <% for (var i = 0, arr = it.obj[key]; i < arr.length; i++) { %> Salutations! Index: <%= i %>, parent key: <%= key %> <% } %> <% } %> <% } %> Partial: <%~ include("mypartial") %>
eta.compile()
Data
"htmlstuff": "
alert('hey')
alert('hey')
alert('hey')
", "arr": ["Hey", "
Malicious XSS
", "Hey", 3, 12], "obj": { "firstchild": "this is a lowercase string", "secondchild": "HEY", "thirdchild": [3, 6, 3, 2, 5, 4] }
Result