Escape HTML special characters with {%=o.prop%}0ms ‣
expect(tmpl('{%=o.special%}', data)).to.equal('<>&"'')
Allow HTML special characters with {%#o.prop%}0ms ‣
expect(tmpl('{%#o.special%}', data)).to.equal('<>&"\'\x00')
Function call0ms ‣
expect(tmpl('{%=o.func()%}', data)).to.equal('value')
Dot notation0ms ‣
expect(tmpl('{%=o.deep.value%}', data)).to.equal('value')
Handle single quotes0ms ‣
expect(tmpl("'single quotes'{%=\": '\"%}", data)).to.equal(
"'single quotes': '"
)
Handle double quotes0ms ‣
expect(tmpl('"double quotes"{%=": \\""%}', data)).to.equal(
'"double quotes": "'
)
Handle backslashes0ms ‣
expect(tmpl('\\backslashes\\{%=": \\\\"%}', data)).to.equal(
'\\backslashes\\: \\'
)
Interpolate escaped falsy values except undefined or null0ms ‣
expect(
tmpl(
'{%=o.undefinedValue%}' +
'{%=o.nullValue%}' +
'{%=o.falseValue%}' +
'{%=o.zeroValue%}',
data
)
).to.equal('false0')
Interpolate unescaped falsy values except undefined or null0ms ‣
expect(
tmpl(
'{%#o.undefinedValue%}' +
'{%#o.nullValue%}' +
'{%#o.falseValue%}' +
'{%#o.zeroValue%}',
data
)
).to.equal('false0')
Preserve whitespace1ms ‣
expect(tmpl('\n\r\t{%=o.value%} \n\r\t{%=o.value%} ', data)).to.equal(
'\n\r\tvalue \n\r\tvalue '
)