silly-ejs
v0.1.1
Published
simple and small implement for EJS
Downloads
24
Readme
silly-ejs
A simple and small implement for EJS
Install
npm
npm i silly-ejs --save
bower
bower install silly-ejs
Usage
var ejs = require('silly-ejs');
var tpl = '<div><%= name %><% if (age > 17) { %>(adult)<% } %> <%- html %></div>';
var data = {
name: 'Hans Chan',
age: 18,
html: '<p>test</p>'
};
var html = ejs(tpl, data);
console.log(html);
// '<div>Hans Chan(adult) <p>test</p></div>'
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:
var ejs = require('silly-ejs');
//Custom delimiters
ejs.delimiters = '$';
var tpl = '<div><$= name $><$ if (age > 17) { %>(adult)<% } $></div>';
var data = {
name: 'Hans Chan',
age: 18
};
var html = ejs(tpl, data);
console.log(html);
// '<div>Hans Chan(adult)</div>'