v2.0.0-beta.1
Pre-release
Pre-release
·
2 commits
to master
since this release
Changes/additions:
- ES6 code generated
- types: https://github.com/olado/doT/blob/v2/doT.d.ts
varnameoption renamed toargName- support templates without explicit context "it" - the list of properties should be passed as array to
argNameoption, template function will expect an object and will destructure it into multiple arguments - so it is nearly zero-cost:
const tmpl = doT.template("{{=foo}}{{=bar}}", {argName: ["foo", "bar"]})
tmpl({foo: 1, bar: 2}) // "12"- partial options can be passed, global options object will not be available in the next release.
- custom encoders:
- syntax
{{<encoder name>! it.foo}}, encoders passed toencodersoption object ( is any valid JS identifier) as functions (or as code strings inselfContained: truemode). - HTML encoding with syntax
{{! it.foo }}requires passing{encoders: {"": require("dot/encodeHTML")}}options
- syntax
- type safe interpolation (maybe
%should be dropped...):{{%n= it.foo}}-it.foomust be number (or exception will be thrown){{%s= it.foo}}- string{{%b= it.foo}}- boolean
- support iterables for
{{~iter:x}}and{{~iter:x:i}}syntaxes (now uses for-of loop). - syntax is no longer in options
- configurable delimiters:
- e.g.
{delimiters: {start: "<%", end: "%>"}}via options to change for one template - or
setDelimiters({start: "<%", end: "%>"})to change globally
- e.g.
- reduces internal variables names usage, two configurable name prefixes are used, can be changed via options (
internalPrefix: "_val",encodersPrefix: "_enc"). - optional iterator index variable is now local (with
let)
Removed:
- doT.process (possibly will be added if there is an interest)
- browser bundle (possibly will be added if there is a substantial interest)
- dot-packer - can be added as a separate module to dot-template org
- legacy doU engine
append: falseoption (onlyappend: truenow, that is faster and that was default anyway)- no HTML interpolation by default (see custom encoders above)