Escape HTML special characters with print(data)0ms ‣
expect(tmpl('{% print(o.special); %}', data)).to.equal(
'<>&"''
)
Allow HTML special characters with print(data, true)0ms ‣
expect(tmpl('{% print(o.special, true); %}', data)).to.equal('<>&"\'\x00')
Print out escaped falsy values except undefined or null0ms ‣
expect(
tmpl(
'{% print(o.undefinedValue); %}' +
'{% print(o.nullValue); %}' +
'{% print(o.falseValue); %}' +
'{% print(o.zeroValue); %}',
data
)
).to.equal('false0')
Print out unescaped falsy values except undefined or null0ms ‣
expect(
tmpl(
'{% print(o.undefinedValue, true); %}' +
'{% print(o.nullValue, true); %}' +
'{% print(o.falseValue, true); %}' +
'{% print(o.zeroValue, true); %}',
data
)
).to.equal('false0')
Include template0ms ‣
expect(
tmpl('{% include("template", {value: "value"}); %}', data)
).to.equal('value')
If condition0ms ‣
expect(
tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data)
).to.equal('true')
Else condition0ms ‣
expect(
tmpl(
'{% if (o.undefinedValue) { %}false{% } else { %}true{% } %}',
data
)
).to.equal('true')
For loop0ms ‣
expect(
tmpl(
'{% for (var i=0; i<o.list.length; i++) { %}' +
'{%=o.list[i]%}{% } %}',
data
)
).to.equal('12345')
For loop print call0ms ‣
expect(
tmpl(
'{% for (var i=0; i<o.list.length; i++) {' + 'print(o.list[i]);} %}',
data
)
).to.equal('12345')
For loop include template0ms ‣
expect(
tmpl(
'{% for (var i=0; i<o.list.length; i++) {' +
'include("template", {value: o.list[i]});} %}',
data
).replace(/[\r\n]/g, '')
).to.equal('12345')
Modulo operator0ms ‣
expect(
tmpl(
'{% if (o.list.length % 5 === 0) { %}5 list items{% } %}',
data
).replace(/[\r\n]/g, '')
).to.equal('5 list items')