Detalhes do pacote

es6template

zalmoxisus26.6kMIT1.0.5

Easy and small template engine for the browser.

easy, ecma, ecmascript, engine

readme (leia-me)

es6-template npmjs.com The MIT License

Easy and small template engine for the browser and nodejs.

code climate standard code style travis build status coverage status dependency status

Install

npm i es6-template --save

Usage

For more use-cases see the tests

var es6template = require('es6-template')

es6template

Acts like .render by default. Renders given str with locals.

  • str {String} template to populate with locals
  • locals {Object} locals object
  • return {String} rendered string

Example

es6template('foo ${bar} baz ${quux}', {bar: 'BAR'}, {quux: 'QUUX'})
//=> 'foo BAR baz QUUX'

.render

Renders given str with locals. 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 with locals
  • locals {Object} locals object
  • return {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 locals object arguments.

  • str {String} template to populate
  • return {Function} which accepts locals objects

Example

var fn = es6template.compile('Hello ${place} and ${user.name}!')
fn({place: 'world', user: {name: 'Charlike'}})
//=> 'Hello world and Charlike!'

Related

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.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

changelog (log de mudanças)

1.0.3 - 2015-10-15

  • Release v1.0.3 / npm@v1.0.3
  • use lazy-cache - add utils.js for browserify-friendly lazyness

1.0.2 - 2015-10-15

  • Release v1.0.2 / npm@v1.0.2
  • update travis
  • add one more test
  • merge #1 - render empty strings like ES6 does

1.0.1 - 2015-10-01

  • Release v1.0.1 / npm@v1.0.1
  • update and docs

1.0.0 - 2015-09-21

  • Release v1.0.0 / npm@v1.0.0
  • update keywords
  • update tests
  • add related
  • docs
  • escaping

0.1.0 - 2015-09-20

  • publish on npm as 0.1.0
  • update readme
  • implement :cat2:

0.0.0 - 2015-09-20

  • Initial commit