Comparison of Dust.js and JavaScript Syntax
Dust.js is a JavaScript templating engine, though there are some differences of the syntax between Dust.js and JavaScript.
Identifier
Dust.js | Template Syntax Reference:
A Dust key is one or more of the following characters: a-z, A-Z, _ (underscore), $, 0-9, or -
NOTE: The first character of a reference cannot be 0-9 or -.
vs.
Grammar and types - JavaScript | MDN:
A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).
You can use most of ISO 8859-1 or Unicode letters such as å and ü in identifiers. You can also use the Unicode escape sequences as characters in identifiers.
Conclusion:
Dust.js allows - (minus sign) while JavaScript does not;
JavaScript allows Unicode letters while Dust.js does not.
Truthy / Falsy
Truth test is done in Dust.js for {#section/}, {?exists/} and {^not-exists/}.
| Dust.js | JavaScript | |
|---|---|---|
| true | Truthy | Truthy | 
| {} | Truthy | Truthy | 
| false | Falsy | Falsy | 
| "" | Falsy | Falsy | 
| 0 | Truthy | Falsy | 
| [] | Falsy | Truthy | 
Section Iteration
In Dust.js, during the execution of the section iteration ({#names}...{/names}), two variables are defined:
- 
$idx- the index of the current iteration starting with zero; and
- 
$len- the number of elements in the data being iterated.