es6-templates
Compiles JavaScript written using template strings to use ES5-compatible syntax. For example, this:
var name = "Nicholas" msg = `Hello, !`; console; // "Hello, Nicholas!"
compiles to this:
var name = "Nicholas" msg = "Hello, " + name + "!"; console; // "Hello, Nicholas!"
For more information about the proposed syntax, see the TC39 wiki page on template strings.
Install
$ npm install es6-templates
Usage
$ node> var compile = compile;> 'code': ... 'map': ...
Without interpolation:
`Hey!`// becomes'"Hey!"'
With interpolation:
`Hey, !`// becomes"Hey, " + name + "!"
With a tag expression:
escape `<a href=""></a>`// becomes;
Or work directly with the AST:
$ node> var transform = transform;>
Transforming ASTs is best done using recast to preserve formatting where possible and for generating source maps.
Browserify
Browserify support is built in.
$ npm install es6-templates # install local dependency
$ browserify -t es6-templates $file
Contributing
Setup
First, install the development dependencies:
$ npm install
Then, try running the tests:
$ npm test
Pull Requests
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Any contributors to the master es6-templates repository must sign the Individual Contributor License Agreement (CLA). It's a short form that covers our bases and makes sure you're eligible to contribute.
When you have a change you'd like to see in the master repository, send a pull request. Before we merge your request, we'll make sure you're in the list of people who have signed a CLA.