render-stencil
v0.0.1
Published
[![Travis branch](https://img.shields.io/travis/JordanSinko/render-stencil/master.svg)](https://travis-ci.org/JordanSinko/render-stencil) [![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=com.jordansinko.render-stencil&metric=
Downloads
18
Readme
render-stencil
Overview
Installation
npm install render-stencil
API
render-stencil(template, variables, options)
Description
// Works with objects and arrays:
const render = require('render-stencil');
const stencil = { name: '{{name}}', hobbies: ['{{hobby}}'] };
const rendered = render(stencil, { name: 'John', hobby: 'coding' }); // -> { name: 'John', hobbies: ['coding'] }
// Works with nested views:
const render = require('render-stencil');
const stencil = { name: '{{name.first}}' };
const rendered = render(stencil, { name: { first: 'John' } }); // -> { name: 'John' }
// Works with strings:
const render = require('render-stencil');
const rendered = render('Hello, {{name}}!', { name: 'John' }); // -> Hello, John!
// If you only need to replace string stencils, then you can also do this:
const render = require('render-stencil/string');
const rendered = render('Hello, {{name}}!', { name: 'John' }); // -> Hello, John!
License
MIT