Deviopath › TypeScript

Mini Template Engine

Hard · Parsing

Write render(template, data).

- {{ path }} (spaces optional) is replaced by the value at a dotted path like user.name. undefined/null render as "", arrays as their items joined with ", ", anything else with String(value).

- Filters run left to right: {{ name | lower | capitalize }}. Supported: upper, lower, capitalize (first character upper-case, rest unchanged) and length (array or string length). A missing value becomes "" before filters run.

- {{#each path}}...{{/each}} renders the body once per item of the array at path (nothing if it is not an array). Inside the body, this is the item, this.x a property of it, @index the 0-based index; other paths are read from data. Loops are never nested.

Next: Spreadsheet Formulas