@hanye9895/vue-template-ast-to-template
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Vue-Template-Ast-To-Template

Transform compiled template ast to vue template.It expose all key vue template property hook for you to overwrite.So you can transform vue template to other template base on vue template ast.

How to

Install

npm install vue-template-transformer --save

Usage

const TemplateTransform = require('vue-template-transformer')

// extend the base template transform
class NewTemplateTransform extends TemplateTransform {
  genVIf (node) {
    // do something for v-if directive
  },
  genVFor (node) {
    // do something for v-for directive
  }
}

// get an instance
const newTemplateTranformer = new NewTemplateTransform({
  // some options
  prefix: 'foo'
})

// inject the origin vue template ast and call generate method of transformer instance to get the transformed template
const { code } = newTemplateTranformer.generate(ast)

All instance properties that can be overwrite:

Directives

  • genVIf(v-if)
  • genVFor(v-for)
  • genEvents(v-on|@)
  • genVShow(v-show)
  • genVModel(v-model)
  • genVOnce(v-once)
  • genVBind(v-bind|:)
  • genVCloak(v-cloak)
  • genVHtml(v-html)
  • genVPre(v-pre)
  • genVText(v-text)

Attrs

  • genAttrs
  • genStyle
  • genClass
  • genKey
  • genIs
  • genRef
  • genSlot
  • genScopedSlot

Readme

Keywords

none

Package Sidebar

Install

npm i @hanye9895/vue-template-ast-to-template

Weekly Downloads

1

Version

0.1.2

License

ISC

Unpacked Size

37.7 kB

Total Files

21

Last publish

Collaborators

  • hanye9895