Skip to content

Commit 63a0889

Browse files
committed
Remove semi-documented _setup and _child APIs
These were a bad idea to begin with and without the trackIds implementation they don’t make much sense.
1 parent 0f054ef commit 63a0889

3 files changed

Lines changed: 4 additions & 64 deletions

File tree

lib/handlebars/compiler/compiler.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -461,25 +461,12 @@ export function compile(input, options = {}, env) {
461461
}
462462

463463
// Template is only compiled on first use and cached after that point.
464-
function ret(context, execOptions) {
464+
return function(context, execOptions) {
465465
if (!compiled) {
466466
compiled = compileInput();
467467
}
468468
return compiled.call(this, context, execOptions);
469-
}
470-
ret._setup = function(setupOptions) {
471-
if (!compiled) {
472-
compiled = compileInput();
473-
}
474-
return compiled._setup(setupOptions);
475-
};
476-
ret._child = function(i, data, blockParams, depths) {
477-
if (!compiled) {
478-
compiled = compileInput();
479-
}
480-
return compiled._child(i, data, blockParams, depths);
481469
};
482-
return ret;
483470
}
484471

485472
function argEquals(a, b) {

lib/handlebars/runtime.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function template(templateSpec, env) {
129129
function ret(context, options = {}) {
130130
let data = options.data;
131131

132-
ret._setup(options);
132+
_setup(options);
133133
if (!options.partial && templateSpec.useData) {
134134
data = initData(context, data);
135135
}
@@ -151,7 +151,7 @@ export function template(templateSpec, env) {
151151
}
152152
ret.isTop = true;
153153

154-
ret._setup = function(options) {
154+
function _setup(options) {
155155
if (!options.partial) {
156156
container.helpers = container.merge(options.helpers, env.helpers);
157157

@@ -166,18 +166,8 @@ export function template(templateSpec, env) {
166166
container.partials = options.partials;
167167
container.decorators = options.decorators;
168168
}
169-
};
170-
171-
ret._child = function(i, data, blockParams, depths) {
172-
if (templateSpec.useBlockParams && !blockParams) {
173-
throw new Exception('must pass block params');
174-
}
175-
if (templateSpec.useDepths && !depths) {
176-
throw new Exception('must pass parent depths');
177-
}
169+
}
178170

179-
return wrapProgram(container, i, templateSpec[i], data, 0, blockParams, depths);
180-
};
181171
return ret;
182172
}
183173

spec/runtime.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,6 @@ describe('runtime', function() {
3232
});
3333
});
3434

35-
describe('#child', function() {
36-
if (!Handlebars.compile) {
37-
return;
38-
}
39-
40-
it('should throw for depthed methods without depths', function() {
41-
shouldThrow(function() {
42-
var template = Handlebars.compile('{{#foo}}{{../bar}}{{/foo}}');
43-
// Calling twice to hit the non-compiled case.
44-
template._setup({});
45-
template._setup({});
46-
template._child(1);
47-
}, Error, 'must pass parent depths');
48-
});
49-
50-
it('should throw for block param methods without params', function() {
51-
shouldThrow(function() {
52-
var template = Handlebars.compile('{{#foo as |foo|}}{{foo}}{{/foo}}');
53-
// Calling twice to hit the non-compiled case.
54-
template._setup({});
55-
template._setup({});
56-
template._child(1);
57-
}, Error, 'must pass block params');
58-
});
59-
it('should expose child template', function() {
60-
var template = Handlebars.compile('{{#foo}}bar{{/foo}}');
61-
// Calling twice to hit the non-compiled case.
62-
equal(template._child(1)(), 'bar');
63-
equal(template._child(1)(), 'bar');
64-
});
65-
it('should render depthed content', function() {
66-
var template = Handlebars.compile('{{#foo}}{{../bar}}{{/foo}}');
67-
// Calling twice to hit the non-compiled case.
68-
equal(template._child(1, undefined, [], [{bar: 'baz'}])(), 'baz');
69-
});
70-
});
71-
7235
describe('#noConflict', function() {
7336
if (!CompilerContext.browser) {
7437
return;

0 commit comments

Comments
 (0)