Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alex8088/ejst
A embedded javascript template engine for nodejs
https://github.com/alex8088/ejst
ejs ejst javascript jst node template
Last synced: about 1 month ago
JSON representation
A embedded javascript template engine for nodejs
- Host: GitHub
- URL: https://github.com/alex8088/ejst
- Owner: alex8088
- License: mit
- Created: 2019-07-01T06:04:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-26T01:59:07.000Z (over 5 years ago)
- Last Synced: 2024-11-15T10:57:39.348Z (about 2 months ago)
- Topics: ejs, ejst, javascript, jst, node, template
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ejst
A embedded javascript template engine for nodejs.
- Auto cache template file to improving performance
- Include feature## Installation
```bash
$ npm install ejst --save
```## Usage
### Render string template
```js
const ejst = require('ejst')// render HTML string
let str = ejst.render('<%=title%>
', { title: 'Hello' })
console.log(str)
```### Render file template
```html
<% if(typeof title === 'string'){ %>
<%=title%>
<% } %>
<%=content%>
<% for(var i = 0; i < buttons.length; i++){ %>
<%=include('./examples/include.html', {button: buttons[i]})%>
<% } %>
``````html
```js
const ejst = require('ejst')// render HTML file
let data = {
title: 'Question',
content: 'Are you sure?',
buttons: [{ label: 'Yes', type: 'green' }, { label: 'No', type: 'gray' }]
}let str = ejst.renderFile('./examples/index.html', data)
console.log(str)
```### Include
```html
<% for(var i = 0; i < buttons.length; i++){ %>
<%=include('./examples/include.html', {button: buttons[i]})%>
<% } %>
```## License
[MIT](./LICENSE)