@marcopeg/template
v1.12.0
Published
Minimalist variable substitution utility
Downloads
183
Maintainers
Readme
@marcopeg/template
Minimalist variable substitution utility inspired by mustache that implements just few variable substitution features.
- no loops
- no conditionals
- no filters
If you need a full template engine, use
mustache
:-)
import template from '@marcopeg/template'
const data = {
name: 'marco',
surname: 'pegoraro',
family: {
father: { name: 'piero' },
mother: { name: 'teresa' },
siblings: [
{ name: 'giulia' },
{ name: 'elisa' },
]
}
}
template('name', name)
// -> marco
template('{{ name }} {{ surname }}', data)
// -> marco pegoraro
template('{{ name }} {{ surname }} has {{ family.siblings.$LENGTH }} siblings', data)
// -> marco pegoraro has 2 siblings