Overview
npm install render-stencil
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!
MIT