Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1x 1x 1x 1x 1x 1x 1x 1x | var chalk = require('chalk') var vueCompiler = require('vue-template-compiler') var transpile = require('vue-template-es2015-compiler') module.exports = function compileTemplate (template) { var compiled = vueCompiler.compile(template) Iif (compiled.errors.length) { compiled.errors.forEach(function (msg) { console.error('\n' + chalk.red(msg) + '\n') }) throw new Error('Vue template compilation failed') } else { return { render: toFunction(compiled.render), staticRenderFns: '[' + compiled.staticRenderFns.map(toFunction).join(',') + ']' } } } function toFunction (code) { return transpile('function render () {' + code + '}') } |