Add with block parameter support

Fixes #1042
This commit is contained in:
kpdecker
2015-08-01 15:48:16 -05:00
parent 410141c31e
commit 2a851067b9
2 changed files with 10 additions and 3 deletions
+6 -3
View File
@@ -194,13 +194,16 @@ function registerDefaultHelpers(instance) {
let fn = options.fn;
if (!Utils.isEmpty(context)) {
let data = options.data;
if (options.data && options.ids) {
let data = createFrame(options.data);
data = createFrame(options.data);
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);
options = {data: data};
}
return fn(context, options);
return fn(context, {
data: data,
blockParams: Utils.blockParams([context], [data.contextPath])
});
} else {
return options.inverse(this);
}
+4
View File
@@ -47,6 +47,10 @@ describe('builtin helpers', function() {
var string = '{{#with person}}Person is present{{else}}Person is not present{{/with}}';
shouldCompileTo(string, {}, 'Person is not present');
});
it('with provides block parameter', function() {
var string = '{{#with person as |foo|}}{{foo.first}} {{last}}{{/with}}';
shouldCompileTo(string, {person: {first: 'Alan', last: 'Johnson'}}, 'Alan Johnson');
});
});
describe('#each', function() {