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

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

Awesome Lists containing this project

README

        

# silly-ejs

A simple and small implement for [EJS](http://www.embeddedjs.com/)

[![NPM](https://nodei.co/npm/silly-ejs.png?compact=true)](https://nodei.co/npm/silly-ejs/)

[![Build Status](https://travis-ci.org/csbun/silly-ejs.svg)](https://travis-ci.org/csbun/silly-ejs)
[![Coverage Status](https://coveralls.io/repos/csbun/silly-ejs/badge.svg?branch=master&service=github)](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)
'
```