Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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

<%=button.label%>
```

```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)