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

Function compileToFunctions

static/vuejs/vue.esm.js:9009–9089  ·  view source on GitHub ↗
(
    template,
    options,
    vm
  )

Source from the content-addressed store, hash-verified

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

Callers 1

vue.esm.jsFile · 0.70

Calls 3

compileFunction · 0.70
makeFunctionFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected