summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/handlebars/compiler/compiler.js15
-rw-r--r--lib/handlebars/runtime.js16
-rw-r--r--spec/runtime.js37
3 files changed, 4 insertions, 64 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index 9fa9dd8..040e99a 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -461,25 +461,12 @@ export function compile(input, options = {}, env) {
}
// Template is only compiled on first use and cached after that point.
- function ret(context, execOptions) {
+ return function(context, execOptions) {
if (!compiled) {
compiled = compileInput();
}
return compiled.call(this, context, execOptions);
- }
- ret._setup = function(setupOptions) {
- if (!compiled) {
- compiled = compileInput();
- }
- return compiled._setup(setupOptions);
- };
- ret._child = function(i, data, blockParams, depths) {
- if (!compiled) {
- compiled = compileInput();
- }
- return compiled._child(i, data, blockParams, depths);
};
- return ret;
}
function argEquals(a, b) {
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index a7a9103..5c479a8 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -129,7 +129,7 @@ export function template(templateSpec, env) {
function ret(context, options = {}) {
let data = options.data;
- ret._setup(options);
+ _setup(options);
if (!options.partial && templateSpec.useData) {
data = initData(context, data);
}
@@ -151,7 +151,7 @@ export function template(templateSpec, env) {
}
ret.isTop = true;
- ret._setup = function(options) {
+ function _setup(options) {
if (!options.partial) {
container.helpers = container.merge(options.helpers, env.helpers);
@@ -166,18 +166,8 @@ export function template(templateSpec, env) {
container.partials = options.partials;
container.decorators = options.decorators;
}
- };
-
- ret._child = function(i, data, blockParams, depths) {
- if (templateSpec.useBlockParams && !blockParams) {
- throw new Exception('must pass block params');
- }
- if (templateSpec.useDepths && !depths) {
- throw new Exception('must pass parent depths');
- }
+ }
- return wrapProgram(container, i, templateSpec[i], data, 0, blockParams, depths);
- };
return ret;
}
diff --git a/spec/runtime.js b/spec/runtime.js
index a4830ad..2a85899 100644
--- a/spec/runtime.js
+++ b/spec/runtime.js
@@ -32,43 +32,6 @@ describe('runtime', function() {
});
});
- describe('#child', function() {
- if (!Handlebars.compile) {
- return;
- }
-
- it('should throw for depthed methods without depths', function() {
- shouldThrow(function() {
- var template = Handlebars.compile('{{#foo}}{{../bar}}{{/foo}}');
- // Calling twice to hit the non-compiled case.
- template._setup({});
- template._setup({});
- template._child(1);
- }, Error, 'must pass parent depths');
- });
-
- it('should throw for block param methods without params', function() {
- shouldThrow(function() {
- var template = Handlebars.compile('{{#foo as |foo|}}{{foo}}{{/foo}}');
- // Calling twice to hit the non-compiled case.
- template._setup({});
- template._setup({});
- template._child(1);
- }, Error, 'must pass block params');
- });
- it('should expose child template', function() {
- var template = Handlebars.compile('{{#foo}}bar{{/foo}}');
- // Calling twice to hit the non-compiled case.
- equal(template._child(1)(), 'bar');
- equal(template._child(1)(), 'bar');
- });
- it('should render depthed content', function() {
- var template = Handlebars.compile('{{#foo}}{{../bar}}{{/foo}}');
- // Calling twice to hit the non-compiled case.
- equal(template._child(1, undefined, [], [{bar: 'baz'}])(), 'baz');
- });
- });
-
describe('#noConflict', function() {
if (!CompilerContext.browser) {
return;