diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js index aa0f13e08..0dbe588ea 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 };