https://github.com/maomincoding/babel-plugin-mettle-html
A Babel plugin that compiles the template string in mettle.js into a normal object.
https://github.com/maomincoding/babel-plugin-mettle-html
babel babel-plugin mettle mettlejs
Last synced: 10 months ago
JSON representation
A Babel plugin that compiles the template string in mettle.js into a normal object.
- Host: GitHub
- URL: https://github.com/maomincoding/babel-plugin-mettle-html
- Owner: maomincoding
- License: mit
- Created: 2024-11-15T16:13:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-17T16:37:29.000Z (11 months ago)
- Last Synced: 2025-08-02T16:41:23.856Z (10 months ago)
- Topics: babel, babel-plugin, mettle, mettlejs
- Language: JavaScript
- Homepage: https://maomincoding.github.io/mettle-doc/tool/babelPluginMettle/
- Size: 58.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
# Babel-plugin-mettle-html
A Babel plugin that compiles the template string in mettle.js into a normal object.
## Usage
In your Babel configuration (`.babelrc`, `babel.config.js`, `"babel"` field in package.json, etc), add the plugin:
```js
{
"plugins": [
["babel-plugin-mettle-html"]
]
}
```
### options
#### `tag=html`
By default, `babelPluginMettleHtml` will process all Tagged Templates with a tag function named `html`. To use a different name, use the `tag` option in your Babel configuration:
```js
{"plugins":[
["babel-plugin-mettle-html", {
"tag": "html"
}]
]}
```
### other modes
By default, ` html`` ` will be used as a tag template mode. If there are other scenarios, you can choose to call the expression mode, there are two.
1. The function name is `tem_h`, and the parameter is a template string.
```js
tem_h(`
hello
`);
```
2. The function name is `str_h`, and the parameters are ordinary strings.
```js
str_h('
hello
');
```
> Whether you choose the default mode or call the expression mode, their final output structure is the same. In addition, these modes we can use at the same time.
## License
[MIT](http://opensource.org/licenses/MIT)
Copyright (c) 2022-present, maomincoding