babel-plugin-mettle
v0.1.2
Published
A Babel plugin that compiles the template string in mettle.js into a normal object.
Downloads
22
Maintainers
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:
{
"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:
{"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.
- The function name is
tem_h
, and the parameter is a template string.
tem_h(`<p>hello</p>`);
- The function name is
str_h
, and the parameters are ordinary strings.
str_h('<p>hello</p>');
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
Copyright (c) 2022-present, maomincoding