Projekt

Obecné

Profil

Stáhnout (1.09 KB) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
# babel-plugin-transform-es2015-template-literals
2
3
> Compile ES2015 template literals to ES5
4
5
## Example
6
7
**In**
8
9
```javascript
10
`foo${bar}`;
11
```
12
13
**Out**
14
15
```javascript
16
"foo" + bar;
17
```
18
19
## Installation
20
21
```sh
22
npm install --save-dev babel-plugin-transform-es2015-template-literals
23
```
24
25
## Usage
26
27
### Via `.babelrc` (Recommended)
28
29
**.babelrc**
30
31
```js
32
// without options
33
{
34
  "plugins": ["transform-es2015-template-literals"]
35
}
36
37
// with options
38
{
39
  "plugins": [
40
    ["transform-es2015-template-literals", {
41
      "loose": true,
42
      "spec": true
43
    }]
44
  ]
45
}
46
```
47
48
### Via CLI
49
50
```sh
51
babel --plugins transform-es2015-template-literals script.js
52
```
53
54
### Via Node API
55
56
```javascript
57
require("babel-core").transform("code", {
58
  plugins: ["transform-es2015-template-literals"]
59
});
60
```
61
62
## Options
63
64
### `loose`
65
In loose mode, tagged template literal objects aren't frozen.
66
67
68
### `spec`
69
This option wraps all template literal expressions with `String`. See [babel/babel#1065](https://github.com/babel/babel/issues/1065) for more info.
70
71
**In**
72
73
```javascript
74
`foo${bar}`;
75
```
76
77
**Out**
78
79
```javascript
80
"foo" + String(bar);
81
```