dummy-templater
v1.1.0
Published
## Uso ```js const {templater} = require('templater');
Downloads
2
Readme
dummy-templater
Uso
const {templater} = require('templater');
// Context object properties are referenced as _.<name> into template.
const str1 = "<div>{{_.name}}</div>";
const tte1 = templater(str1);
// Returned function needs context object for replacement
console.log(tte1({
name: "Rodrigo"
}))
const str2 = "La lista de la compra{{map()}}"
// Template constructor can received environment object which members are referenced by its name
const tte2 = templater(str2, {
map: function (this: any) {
return this.values.map((it: string, ix: number) => ` ${ix}-${it}\n`)
}
});
console.log(tte2({
values: ['Cero', 'Uno', 'Dos']
}));