Awesome
mina-sfc
mina single-file-component for wechat mini program, inspried by vue.js
Installation
npm i --save @tinajs/mina-sfc
Usage
node.js:
const { parse } = require('@tinajs/mina-sfc')
console.log(parse(`
<config>{}</config>
<script>console.log('meow~')</script>
`))
output:
{
"_blocks": [{
"type": "config",
"content": "{}",
"attributes": {}
}, {
"type": "script",
"content": "console.log('meow~')",
"attributes": {}
}],
"config": {
"type": "config",
"content": "{}",
"attributes": {}
},
"script": {
"type": "script",
"content": "console.log('meow~')",
"attributes": {}
},
"style": null,
"template": null
}
API
parse(source:String)
Returns sfc object
Mina SFC Object
Block Struct
-
type
The tag name
-
content
The raw content
-
attributes
The attributes object (
[name]: value
)
Special Block
- config
- style
- template
- script
Related
License
MIT © yelo, 2017 - present