es6-template

Easy and small template engine for the browser and nodejs.
Install
npm i es6-template --saveUsage
For more use-cases see the tests
var es6template = require('es6-template')es6template
Acts like
.renderby default. Renders givenstrwithlocals.
str{String} template to populate withlocalslocals{Object} locals objectreturn{String} rendered string
Example
es6template('foo ${bar} baz ${quux}', {bar: 'BAR'}, {quux: 'QUUX'})
//=> 'foo BAR baz QUUX'.render
Renders given
strwithlocals. You can give unlimited number of object arguments after the first - they will be merged and passed as single locals object.
str{String} template to populate withlocalslocals{Object} locals objectreturn{String} rendered string
Example
es6template.render('Hello ${place} and ${user.name}!', {
place: 'world',
user: {
name: 'Charlike'
}
})
//=> 'Hello world and Charlike!'.compile
Compiles given string and returns function which accepts unlimited number of
localsobject arguments.
str{String} template to populatereturn{Function} which acceptslocalsobjects
Example
var fn = es6template.compile('Hello ${place} and ${user.name}!')
fn({place: 'world', user: {name: 'Charlike'}})
//=> 'Hello world and Charlike!'Related
- es6-template-regex: Regular expression for matching es6 template delimiters in a string.
- es6-template-strings: Compile and resolve template strings notation as specified in ES6
- gulp-es6-template: Gulp plugin for
es6-template- easy and small template engine. - gulp-es6-template-strings: Gulp plugin for
es6-template-stringspackage. - j140: Javascript template engine in just 140 bytes, for browser and node - by Jed Schmidt
- jstransformer-es6-template: es6-template support for JSTransformers
- jstransformer-es6-template-strings: es6-template-strings support for JSTransformers
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.