dust.js
is a simple "templating" (string interpolation) library for JavaScript. dustjs-helpers
adds useful tags like @if
.
Here's an example of how it might be used:
That might look like a JavaScript expression with string interpolation inside it... which it is. It's also recommended usage. Here's the documentation for the @if
helper:
That last comment may not be unconditionally true.
eval(dust.compile(template, 'test'));
function test() { // Click to run:
dust.render(
'test',
{ name: inline().value,
foo : inline().value },
function(_, s) {
// Rendered output
inline().value = s;
});
};
// Hijack eval() to show what happens
eval=function(eval) { return function(s) {
inline().value = s;
return eval(s);
}}(eval);
Spoilers: The "default escaping" is HTML &entity;
encoding. \
is not an HTML metacharacter. Try this.
2014-09-17: Reviewed some internal code that was written according to the documentation.
2014-09-17: Emailed security@linkedin.com
.
2014-09-17: Response: We will look into it right away.
2014-11-04: dustjs-helpers
1.4 released. No fix.
2014-11-20: dustjs-helpers
1.5 released. Still no fix, but @if
is marked as "deprecated".
Complaints to @steike