Skip to content

Commit 45edf5d

Browse files
committed
Add readme
1 parent 9e810ff commit 45edf5d

File tree

1 file changed

+47
-0
lines changed
  • packages/babel-plugin-transform-jsx-to-tagged-templates

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# babel-plugin-transform-jsx-to-tagged-templates
2+
3+
This plugin converts JSX into Tagged Templates that work with things like [htm] and [lit-html].
4+
5+
```js
6+
// INPUT:
7+
const Foo = () => <h1>Hello</h1>
8+
9+
// OUTPUT:
10+
const Foo = () => html`<h1>Hello</h1>`
11+
```
12+
13+
## Installation
14+
15+
Grab it from npm:
16+
17+
```sh
18+
npm i -D babel-plugin-transform-jsx-to-tagged-templates
19+
```
20+
21+
... then add it to your Babel config (eg: `.babelrc`):
22+
23+
```js
24+
"plugins": [
25+
"babel-plugin-transform-jsx-to-tagged-templates"
26+
]
27+
]
28+
```
29+
30+
## Options
31+
32+
There's only one option: `tag`. It lets you specify the function to use for prefixing templates. The default is "html":
33+
34+
```js
35+
"plugins": [
36+
[
37+
"babel-plugin-transform-jsx-to-tagged-templates",
38+
{
39+
"tag": "custom.html"
40+
}
41+
]
42+
]
43+
]
44+
```
45+
46+
[htm]: https://github.com/developit/htm
47+
[lit-html]: https://github.com/polymer/lit-html

0 commit comments

Comments
 (0)