Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/egoist/vegito
Simple micro templating with JavaScript expression support.
https://github.com/egoist/vegito
ejs template
Last synced: 3 months ago
JSON representation
Simple micro templating with JavaScript expression support.
- Host: GitHub
- URL: https://github.com/egoist/vegito
- Owner: egoist
- License: mit
- Created: 2017-02-16T06:42:23.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-12-25T14:08:11.000Z (about 3 years ago)
- Last Synced: 2024-10-08T10:11:46.953Z (4 months ago)
- Topics: ejs, template
- Language: JavaScript
- Homepage:
- Size: 259 KB
- Stars: 25
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
463 bytes simple template engine that works for Node.js and browser.## Install
```bash
npm i --save vegito
```CDN: https://unpkg.com/vegito/dist/
## Usage
```js
const vegito = require('vegito')vegito('hello {{ name }}', {name: 'world'})
//=> hello worldvegito(`hello {{ name.toUpperCase().split('').join('-') }}`, {name: 'world'})
//=> hello W-O-R-L-Dvegito(`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
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D## Author
**vegito** © [egoist](https://github.com/egoist), Released under the [MIT](./LICENSE) License.
Authored and maintained by egoist with help from contributors ([list](https://github.com/egoist/vegito/contributors)).> [egoistian.com](https://egoistian.com) · GitHub [@egoist](https://github.com/egoist) · Twitter [@_egoistlily](https://twitter.com/_egoistlily)