Simple micro templating with JavaScript expression support.
npm install vegito
![]()
463 bytes simple template engine that works for Node.js and browser.
``bash`
npm i --save vegito
CDN: https://unpkg.com/vegito/dist/
`js
const vegito = require('vegito')
vegito('hello {{ name }}', {name: 'world'})
//=> hello world
vegito(hello {{ name.toUpperCase().split('').join('-') }}, {name: 'world'})
//=> hello W-O-R-L-D
vegito(hello {{ reverse('world') }}, {`
reverse: str => str.split('').reverse().join('')
})
//=> hello dlrow
You can use any JavaScript expression in the template within delimiters {{ and }}.
#### template
Type: string''
Default:
Template string.
#### data
Type: Object{}
Default:
#### options
##### delimiters
Type: Array['{{', '}}']
Default:
Change the expression interpolation delimiters.
##### safe
Type: Booleanfalse
Default:
Set safe to true to disable JavaScript expressions in template, this way you can only reference variables.
##### sanitize
Type: function
Sanitize template when safe is false.
1. Fork it!
2. Create your feature branch: git checkout -b my-new-featuregit commit -am 'Add some feature'
3. Commit your changes: git push origin my-new-feature`
4. Push to the branch:
5. Submit a pull request :D
vegito © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).
> egoistian.com · GitHub @egoist · Twitter @rem_rin_rin