0.2.2 • Published 6 years ago

@tinajs/mina-sfc v0.2.2

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

mina-sfc

mina single-file-component for wechat mini program, inspried by vue.js

npm license PRs Welcome

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