Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maomincoding/babel-plugin-mettle
A Babel plugin that compiles the template string in amazed.js into a normal object.
https://github.com/maomincoding/babel-plugin-mettle
babel babel-plugin mettle mettlejs
Last synced: about 1 month ago
JSON representation
A Babel plugin that compiles the template string in amazed.js into a normal object.
- Host: GitHub
- URL: https://github.com/maomincoding/babel-plugin-mettle
- Owner: maomincoding
- License: mit
- Created: 2024-11-15T16:13:53.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-18T07:38:42.000Z (about 1 month ago)
- Last Synced: 2024-11-18T07:49:27.657Z (about 1 month ago)
- Topics: babel, babel-plugin, mettle, mettlejs
- Language: JavaScript
- Homepage:
- Size: 52.7 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
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"]
]
}
```### options
#### `tag=html`
By default, `babelPluginMettle` 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", {
"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