@@ -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);
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user