Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 1.41 KB

README.md

File metadata and controls

44 lines (31 loc) · 1.41 KB

render-stencil

Travis branch Sonarcloud Status npm npm

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