Use env.VM to lookup runtime methods
Allows for overrides by 3rd parties Fixes #679
This commit is contained in:
+11
-16
@@ -27,25 +27,20 @@ export function template(templateSpec, env) {
|
|||||||
throw new Error("No environment passed to template");
|
throw new Error("No environment passed to template");
|
||||||
}
|
}
|
||||||
|
|
||||||
var invokePartialWrapper;
|
// Note: Using env.VM references rather than local var references throughout this section to allow
|
||||||
if (env.compile) {
|
// for external users to override these as psuedo-supported APIs.
|
||||||
invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
|
var invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
|
||||||
// TODO : Check this for all inputs and the options handling (partial flag, etc). This feels
|
var result = env.VM.invokePartial.apply(this, arguments);
|
||||||
// like there should be a common exec path
|
if (result != null) { return result; }
|
||||||
var result = invokePartial.apply(this, arguments);
|
|
||||||
if (result != null) { return result; }
|
|
||||||
|
|
||||||
|
if (env.compile) {
|
||||||
var options = { helpers: helpers, partials: partials, data: data };
|
var options = { helpers: helpers, partials: partials, data: data };
|
||||||
partials[name] = env.compile(partial, { data: data !== undefined }, env);
|
partials[name] = env.compile(partial, { data: data !== undefined }, env);
|
||||||
return partials[name](context, options);
|
return partials[name](context, options);
|
||||||
};
|
} else {
|
||||||
} else {
|
|
||||||
invokePartialWrapper = function(partial, name /* , context, helpers, partials, data */) {
|
|
||||||
var result = invokePartial.apply(this, arguments);
|
|
||||||
if (result != null) { return result; }
|
|
||||||
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Just add water
|
// Just add water
|
||||||
var container = {
|
var container = {
|
||||||
@@ -71,8 +66,8 @@ export function template(templateSpec, env) {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
programWithDepth: programWithDepth,
|
programWithDepth: env.VM.programWithDepth,
|
||||||
noop: noop,
|
noop: env.VM.noop,
|
||||||
compilerInfo: null
|
compilerInfo: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user