silly-ejs

0.1.1 • Public • Published

silly-ejs

A simple and small implement for EJS

NPM

Build Status Coverage Status

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>'

Readme

Keywords

Package Sidebar

Install

npm i silly-ejs

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • csbun