Playground
Based on the excellent
DoT.js
website
Template
Hi {{!console.log("Hope you like Squirrelly!");}} {{it.htmlstuff}} {{@foreach(it.obj) => key, val}} Reversed value: {{val|reverse}}, Key: {{key}} {{@if(key==="thirdchild")}} {{@each(it.obj[key]) => index, key}} Salutations! Index: {{index}}, old key: {{key}} {{/each}} {{/if}} {{/foreach}} {{@customhelper()}} {{#cabbage}} Cabbages taste good {{!console.log("Hi from inside a template");}} {{#pineapple}} As do pineapples {{/customhelper}} This is a partial: {{@include("mypartial")/}}
Sqrl.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