How to use the vue-template-compiler/build.compile function in vue-template-compiler

To help you get started, we’ve selected a few vue-template-compiler 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 shuidi-fed / vuese / packages / parser / lib / sfcToAST.ts View on Github external
if (sfc.template) {
    if (!sfc.template.content && sfc.template.src) {
      // Src Imports
      if (basedir) {
        try {
          sfc.template.content = fs.readFileSync(
            path.resolve(basedir, sfc.template.src),
            'utf-8'
          )
        } catch (e) {
          console.error(e)
          sfc.template.content = ''
        }
      }
    }
    res.templateAst = compile(sfc.template.content, {
      comments: true
    }).ast
  }
  return res
}
github max-team / Mars / packages / mars-build / src / compiler / template / mark-component.js View on Github external
} = options;

    let componentsInUsed = {};
    Object.keys(components).forEach(name => {
        if (!componentsInUsed[name]) {
            componentsInUsed[name] = {
                using: false,
                declaration: components[name]
            };
        }
    });

    const {
        ast,
        errors
    } = compileTemplate(source, {
        preserveWhitespace: false,
        modules: [{
            preTransformNode(el, options) {
                // swan doesn't support PascalCase tag name
                // componentsInUsed map is hyphenated
                // so transform h5 tag into hyphenated to match it
                el.tag = hyphenate(el.tag);

                let basicCompMap = {};
                delToVueTag(el, {
                    basicCompMap,
                    componentsInUsed
                });
                Object.assign(componentSet, basicCompMap);
            }
        }]
github max-team / Mars / packages / mars-build / src / compiler / template / mark-component.js View on Github external
let componentsInUsed = {};
    Object.keys(components).forEach(name => {
        if (!componentsInUsed[name]) {
            componentsInUsed[name] = {
                using: false,
                declaration: components[name]
            };
        }
    });

    const {
        ast,
        staticRenderFns,
        errors
    } = compileTemplate(source, {
        preserveWhitespace: false,
        modules: [
            {
                transformNode: getMarkNode(options, componentsInUsed),
                postTransformNode: getPostTrans(options)
            }
        ]
    });

    const render = generate(ast, {
        processFilterData: getGenData(),
        isComplexExp,
        isFilter,
        isInFor,
        getIterators
    });