es6-template-strings

WebJar for es6-template-strings

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

es6-template-strings
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

es6-template-strings
WebJar for es6-template-strings
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/medikoo/es6-template-strings

Download es6-template-strings

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/es6-template-strings/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>es6-template-strings</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/es6-template-strings/
implementation 'org.webjars.npm:es6-template-strings:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/es6-template-strings/
implementation ("org.webjars.npm:es6-template-strings:2.0.0")
'org.webjars.npm:es6-template-strings:jar:2.0.0'
<dependency org="org.webjars.npm" name="es6-template-strings" rev="2.0.0">
  <artifact name="es6-template-strings" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='es6-template-strings', version='2.0.0')
)
libraryDependencies += "org.webjars.npm" % "es6-template-strings" % "2.0.0"
[org.webjars.npm/es6-template-strings "2.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : es5-ext jar [0.10.7,0.11)
org.webjars.npm : esniff jar [1,2)

Project Modules

There are no modules declared in this project.

es6-template-strings

Compile and resolve template strings notation as specified in ES6

Usage

Basic example:

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 */}));

Partial resolution of a template

With partial: true option, it's possible to resolve just some variables from a template. It's useful when we want to resolve template in more than one pass.

var partialTemplate = template(
  'Hello ${place.toUpperCase()}! Today is ${day}',
  { place: "World" },
  { partial: true }
); // Hello WORLD! Today is ${day}

template(partialTemplate, { day: "Tuesday" }); // Hello WORLD! Today is Tuesday

// Same way `partial` option can go to any resolve* util, e.g.:
resolveToString(compiled, { place: "World" }, { partial: true });

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

Versions

Version
2.0.0