Skip to content

Commit

Permalink
Merge pull request #13049 from emberjs/fix-13045
Browse files Browse the repository at this point in the history
[BUGFIX release] Fixes `{{#with proxy as |foo|}}`
  • Loading branch information
rwjblue committed Mar 5, 2016
2 parents 7e80717 + 29943af commit fce275b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions packages/ember-glimmer/tests/integration/syntax/with-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,34 @@ moduleFor('Syntax test: {{#with as}}', class extends TogglingSyntaxConditionalsT
this.assertText('No Thing bar');
}

['@test can access alias of a proxy']() {
this.render(`{{#with proxyThing as |person|}}{{person.name}}{{/with}}`, {
proxyThing: { isTruthy: true, name: 'Tom Dale' }
});

this.assertText('Tom Dale');

this.runTask(() => this.rerender());

this.assertText('Tom Dale');

this.runTask(() => set(this.context, 'proxyThing.name', 'Yehuda Katz'));

this.assertText('Yehuda Katz');

this.runTask(() => set(this.context, 'proxyThing.isTruthy', false));

this.assertText('');

this.runTask(() => set(this.context, 'proxyThing.name', 'Godfrey Chan'));

this.assertText('');

this.runTask(() => set(this.context, 'proxyThing', { isTruthy: true, name: 'Tom Dale' }));

this.assertText('Tom Dale');
}

['@test can access alias of an array']() {
this.render(`{{#with arrayThing as |words|}}{{#each words as |word|}}{{word}}{{/each}}{{/with}}`, {
arrayThing: emberA(['Hello', ' ', 'world'])
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/lib/hooks/link-render-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ function shouldDisplay(predicate, coercer) {
let isTruthyVal = read(isTruthy);

if (isArray(predicateVal)) {
return lengthVal > 0 ? predicateVal : false;
return lengthVal > 0 ? coercer(predicateVal) : false;
}

if (typeof isTruthyVal === 'boolean') {
return isTruthyVal;
return isTruthyVal ? coercer(predicateVal) : false;
}

return coercer(predicateVal);
Expand Down

0 comments on commit fce275b

Please sign in to comment.