babel-plugin-mettle 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
1
|
# Babel-plugin-mettle
|
|
2
2
|
|
|
3
|
-
A Babel plugin that compiles the template string in mettle.js into a normal object.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
In your Babel configuration (`.babelrc`, `babel.config.js`, `"babel"` field in package.json, etc), add the plugin:
|
|
8
|
-
|
|
9
|
-
```js
|
|
10
|
-
{
|
|
11
|
-
"plugins": [
|
|
12
|
-
["babel-plugin-mettle"]
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### options
|
|
18
|
-
|
|
19
|
-
#### `tag=html`
|
|
20
|
-
|
|
21
|
-
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:
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
{"plugins":[
|
|
25
|
-
["babel-plugin-mettle", {
|
|
26
|
-
"tag": "html"
|
|
27
|
-
}]
|
|
28
|
-
]}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### other modes
|
|
32
|
-
|
|
33
|
-
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.
|
|
34
|
-
|
|
35
|
-
1. The function name is `tem_h`, and the parameter is a template string.
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
tem_h(`<p>hello</p>`);
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
2. The function name is `str_h`, and the parameters are ordinary strings.
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
str_h('<p>hello</p>');
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
> 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.
|
|
48
|
-
|
|
49
3
|
## License
|
|
50
4
|
|
|
51
5
|
[MIT](http://opensource.org/licenses/MIT)
|
|
52
6
|
|
|
53
|
-
Copyright (c)
|
|
7
|
+
Copyright (c) 2025-present, maomincoding
|
package/package.json
CHANGED