MCPcopy Create free account
hub / github.com/TruthHun/BookStack / compileToFunctions

Function compileToFunctions

static/vuejs/vue.common.js:9011–9091  ·  view source on GitHub ↗
(
    template,
    options,
    vm
  )

Source from the content-addressed store, hash-verified

9009 }
9010
9011 function compileToFunctions (
9012 template,
9013 options,
9014 vm
9015 ) {
9016 options = options || {};
9017
9018 /* istanbul ignore if */
9019 if (process.env.NODE_ENV !== 'production') {
9020 // detect possible CSP restriction
9021 try {
9022 new Function('return 1');
9023 } catch (e) {
9024 if (e.toString().match(/unsafe-eval|CSP/)) {
9025 warn(
9026 'It seems you are using the standalone build of Vue.js in an ' +
9027 'environment with Content Security Policy that prohibits unsafe-eval. ' +
9028 'The template compiler cannot work in this environment. Consider ' +
9029 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
9030 'templates into render functions.'
9031 );
9032 }
9033 }
9034 }
9035
9036 // check cache
9037 var key = options.delimiters
9038 ? String(options.delimiters) + template
9039 : template;
9040 if (functionCompileCache[key]) {
9041 return functionCompileCache[key]
9042 }
9043
9044 // compile
9045 var compiled = compile(template, options);
9046
9047 // check compilation errors/tips
9048 if (process.env.NODE_ENV !== 'production') {
9049 if (compiled.errors && compiled.errors.length) {
9050 warn(
9051 "Error compiling template:\n\n" + template + "\n\n" +
9052 compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
9053 vm
9054 );
9055 }
9056 if (compiled.tips && compiled.tips.length) {
9057 compiled.tips.forEach(function (msg) { return tip(msg, vm); });
9058 }
9059 }
9060
9061 // turn code into functions
9062 var res = {};
9063 var fnGenErrors = [];
9064 res.render = makeFunction(compiled.render, fnGenErrors);
9065 var l = compiled.staticRenderFns.length;
9066 res.staticRenderFns = new Array(l);
9067 for (var i = 0; i < l; i++) {
9068 res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors);

Callers 1

vue.common.jsFile · 0.70

Calls 3

compileFunction · 0.70
makeFunctionFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected