You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Support for HTML comments: `<div><!-- don't delete this! --></div>`
47
-
- Syntax highlighting and language support via the [lit-html VSCode extension].
48
-
49
-
## Project Status
50
-
51
-
The original goal for `htm` was to create a wrapper around Preact that felt natural for use untranspiled in the browser. I wanted to use Virtual DOM, but I wanted to eschew build tooling and use ES Modules directly.
52
-
53
-
This meant giving up JSX, and the closest alternative was [Tagged Templates]. So, I wrote this library to patch up the differences between the two as much as possible. As it turns out, the technique is framework-agnostic, so it should work great with most Virtual DOM libraries.
44
+
- Syntax highlighting and language support via the [literaly VSCode extension].
**Webpack configuration via [jsxobj]:** ([details here](https://webpack.js.org/configuration/configuration-languages/#babel-and-jsx))
188
+
**Webpack configuration via [jsxobj]:** ([details here](https://webpack.js.org/configuration/configuration-languages/#babel-and-jsx))_(never do this)_
196
189
197
190
```js
198
191
importhtmfrom'htm';
@@ -214,9 +207,17 @@ console.log(html`
214
207
// }
215
208
```
216
209
210
+
## Project Status
211
+
212
+
The original goal for `htm` was to create a wrapper around Preact that felt natural for use untranspiled in the browser. I wanted to use Virtual DOM, but I wanted to eschew build tooling and use ES Modules directly.
213
+
214
+
This meant giving up JSX, and the closest alternative was [Tagged Templates]. So, I wrote this library to patch up the differences between the two as much as possible. As it turns out, the technique is framework-agnostic, so it should work great with most Virtual DOM libraries.
215
+
216
+
As of 2.0.0, `htm` is stable, well-tested and ready for production use.
The target "hyperscript" function to compile elements to (see [Babel docs]).
30
30
Defaults to: `"h"`.
31
31
32
+
### `tag=html`
33
+
34
+
By default, `babel-plugin-htm` will process all Tagged Templates with a tag function named `html`. To use a different name, use the `tag` option in your Babel configuration:
35
+
36
+
```js
37
+
{"plugins":[
38
+
["babel-plugin-htm", {
39
+
"tag":"myCustomHtmlFunction"
40
+
}]
41
+
]}
42
+
```
43
+
44
+
### `useBuiltIns=false`
45
+
46
+
`babel-plugin-htm` transforms prop spreads (`<a ...${b}>`) into `Object.assign()` calls. For browser support reasons, Babel's standard `_extends` helper is used by default. To use native `Object.assign` directly, pass `{useBuiltIns:true}`.
47
+
48
+
### `variableArity=true`
49
+
50
+
By default, `babel-plugin-htm` transpiles to the same output as JSX would, which assumes a target function of the form `h(type, props, ...children)`. If, for the purposes of optimization or simplification, you would like all calls to `h()` to be passed exactly 3 arguments, specify `{variableArity:false}` in your Babel config:
0 commit comments