summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/runtime.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2013-12-23 19:53:11 -0600
committerkpdecker <kpdecker@gmail.com>2013-12-23 19:53:11 -0600
commitabe9c82e753744edcac3c767ce5282a7c9ef7c41 (patch)
tree0ed796a83463010239ec7e425daa2212f3307ddf /lib/handlebars/runtime.js
parent956ac95e7a743745e01bcaa68cd6ae1bb8cf42fd (diff)
downloadhandlebars.js-abe9c82e753744edcac3c767ce5282a7c9ef7c41.zip
handlebars.js-abe9c82e753744edcac3c767ce5282a7c9ef7c41.tar.gz
handlebars.js-abe9c82e753744edcac3c767ce5282a7c9ef7c41.tar.bz2
Use env.VM to lookup runtime methods
Allows for overrides by 3rd parties Fixes #679
Diffstat (limited to 'lib/handlebars/runtime.js')
-rw-r--r--lib/handlebars/runtime.js27
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index aa0f13e..0dbe588 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -27,25 +27,20 @@ export function template(templateSpec, env) {
throw new Error("No environment passed to template");
}
- var invokePartialWrapper;
- if (env.compile) {
- invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
- // TODO : Check this for all inputs and the options handling (partial flag, etc). This feels
- // like there should be a common exec path
- var result = invokePartial.apply(this, arguments);
- if (result != null) { return result; }
+ // Note: Using env.VM references rather than local var references throughout this section to allow
+ // for external users to override these as psuedo-supported APIs.
+ var invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
+ var result = env.VM.invokePartial.apply(this, arguments);
+ if (result != null) { return result; }
+ if (env.compile) {
var options = { helpers: helpers, partials: partials, data: data };
partials[name] = env.compile(partial, { data: data !== undefined }, env);
return partials[name](context, options);
- };
- } else {
- invokePartialWrapper = function(partial, name /* , context, helpers, partials, data */) {
- var result = invokePartial.apply(this, arguments);
- if (result != null) { return result; }
+ } else {
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
- };
- }
+ }
+ };
// Just add water
var container = {
@@ -71,8 +66,8 @@ export function template(templateSpec, env) {
}
return ret;
},
- programWithDepth: programWithDepth,
- noop: noop,
+ programWithDepth: env.VM.programWithDepth,
+ noop: env.VM.noop,
compilerInfo: null
};