vegito
v1.1.0
Published
Simple micro templating with JavaScript expression support.
Downloads
30
Readme
Install
npm i --save vegito
CDN: https://unpkg.com/vegito/dist/
Usage
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 }}
.
API
vegito(template, data, options)
template
Type: string
Default: ''
Template string.
data
Type: Object
Default: {}
options
delimiters
Type: Array
Default: ['{{', '}}']
Change the expression interpolation delimiters.
safe
Type: Boolean
Default: false
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
.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
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