How to use mvvm-babel-generator - 2 common examples

To help you get started, we’ve selected a few mvvm-babel-generator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github didi / chameleon / packages / mvvm-template-parser / lib / process-template.js View on Github external
const parser = require('mvvm-babel-parser');
const t = require('@babel/types');
const traverse = require('@babel/traverse')["default"];
const generate = require('mvvm-babel-generator/lib')["default"];
const _ = module.exports = {};

/* 将vue语法的模板转化为cml语法
主要是将
1 :id="value"  => v-bind:id="value"
2 @click="handleClick" => c-bind:click="handleClick" 或者c-catch
*/

_.vueToCml = function(source,options = {}) {
  // 去掉模板中的注释
  source = _.preDisappearAnnotation(source);
  // 模板中所有的  :id="value" ==>  v-bind:id="value"
  source = _.preParseBindAttr(source);
  // 模板中所有的 @click="handleClick"  => c-bind:click="handleClick"
  source = _.preParseVueEvent(source);
  // 模板通过 @babel/parser进行解析
github didi / chameleon / packages / mvvm-template-parser / lib / process-template.js View on Github external
const parser = require('mvvm-babel-parser');
const t = require('@babel/types');
const traverse = require('@babel/traverse')["default"];
const generate = require('mvvm-babel-generator/lib')["default"];
const _ = module.exports = {};

/* 将vue语法的模板转化为cml语法
主要是将
1 :id="value"  => v-bind:id="value"
2 @click="handleClick" => c-bind:click="handleClick" 或者c-catch
*/

_.vueToCml = function(source,options = {}) {
  // 去掉模板中的注释
  source = _.preDisappearAnnotation(source);
  // 模板中所有的  :id="value" ==>  v-bind:id="value"
  source = _.preParseBindAttr(source);
  // 模板中所有的 @click="handleClick"  => c-bind:click="handleClick"
  source = _.preParseVueEvent(source);
  // 模板通过 @babel/parser进行解析

mvvm-babel-generator

Turns an AST into code.

MIT
Latest version published 4 years ago

Package Health Score

69 / 100
Full package analysis

Popular mvvm-babel-generator functions