es6-template-strings
Compile and resolve template strings notation as specified in ES6
Last updated 4 years ago by medikoo .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install es6-template-strings 
SYNC missed versions from official npm registry.

es6-template-strings

Compile and resolve template strings notation as specified in ES6

Usage


var template = require('es6-template-strings');

// Hello WORLD!
console.log(template('Hello ${place.toUpperCase()}!', { place: "World" }));

// You can reuse same templates:
var compile = require('es6-template-strings/compile')
  , resolveToString = require('es6-template-strings/resolve-to-string')

  , compiled = compile('Welcome to ${siteName}, you are visitor number ${visitorNumber}!');

// Welcome to MySite, you are visitor number 137!
console.log(resolveToString(compiled, { siteName: "MySite", visitorNumber: 137 }));

// Welcome to OtherSite, you are visitor number 777!
console.log(resolveToString(compiled, { siteName: "OtherSite", visitorNumber: 777 }));

// You may prepare custom tag functions
var resolve = require('es6-template-strings/resolve');

var customTag = function (literals/*, …substitutions*/) {
	// Process input and return result string
};

// Output template processed by customTag:
customTag.apply(null, resolve(compiled, {/* context */}));

Installation

NPM

In your project path:

$ npm install es6-template-strings
Browser

You can easily bundle es6-template-strings for browser with modules-webmake

Tests Build Status

$ npm test

Current Tags

  • 2.0.1                                ...           latest (4 years ago)

5 Versions

  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 5
This Week 172
This Month 522
Last Day 27
Last Week 195
Last Month 697
Dependencies (2)
Dev Dependencies (3)
Dependents (122)

Copyright 2014 - 2017 © taobao.org |