https://github.com/csbun/silly-ejs
simple and small implement for [EJS](http://www.embeddedjs.com/)
https://github.com/csbun/silly-ejs
Last synced: about 2 months ago
JSON representation
simple and small implement for [EJS](http://www.embeddedjs.com/)
- Host: GitHub
- URL: https://github.com/csbun/silly-ejs
- Owner: csbun
- License: mit
- Created: 2015-07-14T06:55:09.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-17T09:58:51.000Z (about 9 years ago)
- Last Synced: 2025-02-15T15:13:54.652Z (2 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# silly-ejs
A simple and small implement for [EJS](http://www.embeddedjs.com/)
[](https://nodei.co/npm/silly-ejs/)
[](https://travis-ci.org/csbun/silly-ejs)
[](https://coveralls.io/github/csbun/silly-ejs?branch=master)## Install
### npm
```sh
npm i silly-ejs --save
```### bower
```sh
bower install silly-ejs
```## Usage
```javascript
var ejs = require('silly-ejs');
var tpl = '<%= name %><% if (age > 17) { %>(adult)<% } %> <%- html %>';
var data = {
name: 'Hans Chan',
age: 18,
html: 'test
'
};
var html = ejs(tpl, data);
console.log(html);
// 'Hans Chan(adult)'test
```## Features
- Control flow with `<% %>`
- Escaped output with `<%= %>`
- Unescaped raw output with `<%- %>`
- Custom delimiters (e.g., use `<$ $>` instead of `<% %>`)## Custom delimiters
Custom delimiters can be applied on a per-template basis, or globally:
```javascript
var ejs = require('silly-ejs');//Custom delimiters
ejs.delimiters = '$';var tpl = '
<$= name $><$ if (age > 17) { %>(adult)<% } $>';
var data = {
name: 'Hans Chan',
age: 18
};
var html = ejs(tpl, data);
console.log(html);
// 'Hans Chan(adult)'
```