Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const defaultModules = [
transformRequire(options.transformRequire, loaderContext),
transformSrcset(),
];
const userModules = vueOptions.compilerModules || options.compilerModules;
const compilerOptions = {
preserveWhitespace: options.preserveWhitespace,
modules: defaultModules.concat(userModules || []),
directives:
vueOptions.compilerDirectives || options.compilerDirectives || {},
scopeId: options.hasScoped ? options.id : null,
comments: options.hasComment,
};
const compiled = compiler.compile(html, compilerOptions);
// tips
if (compiled.tips && compiled.tips.length) {
compiled.tips.forEach(tip => {
loaderContext.emitWarning({
name: 'vue-warning',
message: tip,
fileName: loaderContext._module.module.parent
? loaderContext._module.module.parent.path
: loaderContext.path,
lineNumber: 1,
columnNumber: 1,
source: 'vue-template-compiler',
});
});
}
let script = ''
if (!parts.script.lang) {
script = babel(parts.script.content)
} else {
throw filePath + ': unknown
it('should match props in interpolated text', () => {
const ast = compile(
[
'<div>',
' <h1>titleof the template</h1>',
' <button style="width:200px">',
' ',
' ',
' test {{props.name}} {{props.adress}}',
' </button>',
'</div>',
].join('\n'),
{ comments: true },
).ast
if (ast) {
traverse(ast, doc, [propHandler], { functional: true, rootLeadingComment: '' })
expect(doc.toObject().props).toMatchObject({
name: { type: { name: 'mixed' }, description: 'Your Name' },
function generateRender(options) {
const compilerModule = generateCompilerModule(options)
const { render } = compiler.compile(template, {
modules: [compilerModule],
})
return render
}
function compileIt(src: string): ASTElement | undefined {
const ast = compile(src, { comments: true }).ast
if (ast) {
const firstHeader = ast.children.filter((a: ASTElement) => a.tag === 'h1') as ASTElement[]
if (firstHeader.length) {
return firstHeader[0]
}
}
return ast
}
function compilePath(t, path, template) {
const { errors, tips, render, staticRenderFns } = compile(template)
if (errors.length > 0) {
errors.forEach(error => console.error(error))
}
if (tips.length > 0) {
tips.forEach(tip => console.log(tip))
}
const renderFnValue = babelTemplate(stripWith(toFunction(render, 'render')))()
renderFnValue.type = 'FunctionExpression'
const staticRenderFnsValue = babelTemplate(
stripWith(`[${staticRenderFns.map(fn => toFunction(fn)).join(',')}]`)
)().expression
path.parentPath.replaceWithMultiple([
.then(() => vueCompiler.compile(this.contents));
}, Promise.resolve())
function extractFromTemplate(template_block) {
const compiled = vueTemplateCompiler.compile(template_block.content);
if (compiled.errors.length > 0) {
compiled.errors.forEach((error) => log(error));
throw new Error(`Error during Vue template compilation for file: ${file_path}`);
}
parseNode(compiled.ast);
}
function compileTemplateAsModule (name, template) {
name = getTemplateModuleName(name)
var fns = vueCompiler.compile(template)
return `System.set(${JSON.stringify(name)},System.newModule({\n` +
`render:${toFn(fns.render)},\n` +
`staticRenderFns:[${fns.staticRenderFns.map(toFn).join(',')}]\n` +
`}));`
}