File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
packages/babel-plugin-transform-jsx-to-tagged-templates Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments