# es6-templates

> ES6 template strings compiled to ES5.

Latest version **0.2.3** (published 2016-09-02) · Apache 2 license · 0 weekly downloads

## Install

```sh
npm install es6-templates
pnpm add es6-templates
yarn add es6-templates
bun add es6-templates
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2016-09-02 |
| First published | 2014-04-15 |
| Weekly downloads | 0 |
| License | Apache 2 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51 |
| Author | Square, Inc. |
| Maintainers | eventualbuddha |

## Links

- npm: https://www.npmjs.com/package/es6-templates
- Repository: https://github.com/esnext/es6-templates
- Homepage: https://github.com/esnext/es6-templates#readme
- Issues: https://github.com/esnext/es6-templates/issues
- npm.io page: https://npm.io/package/es6-templates

## Dependencies (2)

- [recast](https://npm.io/package/recast.md) ~0.11.12
- [through](https://npm.io/package/through.md) ~2.3.6

## Recent versions

- 0.2.3 (latest) — 2016-09-02
- 0.2.2 — 2014-12-31
- 0.2.1 — 2014-12-31
- 0.2.0 — 2014-10-27
- 0.1.0 — 2014-09-23
- 0.0.3 — 2014-05-02
- 0.0.2 — 2014-04-15
- 0.0.1 — 2014-04-15

## README

# es6-templates

Compiles JavaScript written using template strings to use ES5-compatible
syntax. For example, this:

```js
var name = "Nicholas",
    msg = `Hello, ${name}!`;

console.log(msg);    // "Hello, Nicholas!"
```

compiles to this:

```js
var name = "Nicholas",
    msg = "Hello, " + name + "!";

console.log(msg);    // "Hello, Nicholas!"
```

For more information about the proposed syntax, see the [TC39 wiki page on
template strings](http://tc39wiki.calculist.org/es6/template-strings/).

## Install

```
$ npm install es6-templates
```

## Usage

```js
$ node
> var compile = require('es6-templates').compile;
> compile('`Hey, ${name}!`')
{ 'code': ..., 'map': ... }
```

Without interpolation:

```js
`Hey!`
// becomes
'"Hey!"'
```

With interpolation:

```js
`Hey, ${name}!`
// becomes
"Hey, " + name + "!"
```

With a tag expression:

```js
escape `<a href="${href}">${text}</a>`
// becomes
escape(function() {
  var strings = ["\u003Ca href=\"", "\"\u003E", "\u003C/a\u003E"];
  strings.raw = ["\u003Ca href=\"", "\"\u003E", "\u003C/a\u003E"];
  return strings;
}(), href, text);
```

Or work directly with the AST:

```js
$ node
> var transform = require('es6-templates').transform;
> transform(inputAST)
```

Transforming ASTs is best done using [recast][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

[![Build Status](https://travis-ci.org/esnext/es6-templates.svg?branch=master)](https://travis-ci.org/esnext/es6-templates)

### Setup

First, install the development dependencies:

```
$ npm install
```

Then, try running the tests:

```
$ npm test
```

### Pull Requests

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Any contributors to the master es6-templates repository must sign the
[Individual Contributor License Agreement (CLA)][cla].  It's a short form that
covers our bases and makes sure you're eligible to contribute.

[cla]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1

When you have a change you'd like to see in the master repository, [send a pull
request](https://github.com/esnext/es6-templates/pulls). Before we merge
your request, we'll make sure you're in the list of people who have signed a
CLA.

[recast]: https://github.com/benjamn/recast

---
_Source: https://npm.io/package/es6-templates · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
