Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Fix subexpr {{if}} / {{unless}} to use protocol. #13359

Merged
merged 1 commit into from
Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ moduleFor('Helpers test: inline {{if}}', class extends TogglingHelperConditional

});

moduleFor('@glimmer Helpers test: nested {{if}} helpers (returning truthy values)', class extends TogglingHelperConditionalsTest {
moduleFor('Helpers test: nested {{if}} helpers (returning truthy values)', class extends TogglingHelperConditionalsTest {

templateFor({ cond, truthy, falsy }) {
return `{{if (if ${cond} ${cond} false) ${truthy} ${falsy}}}`;
}

});

moduleFor('@glimmer Helpers test: nested {{if}} helpers (returning falsy values)', class extends TogglingHelperConditionalsTest {
moduleFor('Helpers test: nested {{if}} helpers (returning falsy values)', class extends TogglingHelperConditionalsTest {

templateFor({ cond, truthy, falsy }) {
return `{{if (if ${cond} true ${cond}) ${truthy} ${falsy}}}`;
}

});

moduleFor('@glimmer Helpers test: {{if}} used with another helper', class extends TogglingHelperConditionalsTest {
moduleFor('Helpers test: {{if}} used with another helper', class extends TogglingHelperConditionalsTest {

wrapperFor(templates) {
return `{{concat ${templates.join(' ')}}}`;
Expand Down
19 changes: 12 additions & 7 deletions packages/ember-htmlbars/lib/hooks/link-render-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ export default function linkRenderNode(renderNode, env, scope, path, params, has
let keyword = env.hooks.keywords[path];
if (keyword && keyword.link) {
keyword.link(renderNode.getState(), params, hash);
} else if (path === 'unbound') {
return true;
} else {
switch (path) {
case 'unbound': return true;
case 'unless':
case 'if': params[0] = shouldDisplay(params[0], toBool); break;
case 'each': params[0] = eachParam(params[0]); break;
case 'with': params[0] = shouldDisplay(params[0], identity); break;
}
linkParamsFor(path, params);
}

// If there is a dot in the path, we need to subscribe to the arguments in the
Expand Down Expand Up @@ -65,6 +61,15 @@ export default function linkRenderNode(renderNode, env, scope, path, params, has
return true;
}

export function linkParamsFor(path, params) {
switch (path) {
case 'unless':
case 'if': params[0] = shouldDisplay(params[0], toBool); break;
case 'each': params[0] = eachParam(params[0]); break;
case 'with': params[0] = shouldDisplay(params[0], identity); break;
}
}

function eachParam(list) {
let listChange = getKey(list, '[]');

Expand Down
3 changes: 3 additions & 0 deletions packages/ember-htmlbars/lib/hooks/subexpr.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
labelsFor,
labelFor
} from 'ember-metal/streams/utils';
import { linkParamsFor } from 'ember-htmlbars/hooks/link-render-node';

export default function subexpr(env, scope, helperName, params, hash) {
// TODO: Keywords and helper invocation should be integrated into
Expand All @@ -18,6 +19,8 @@ export default function subexpr(env, scope, helperName, params, hash) {
return keyword(null, env, scope, params, hash, null, null);
}

linkParamsFor(helperName, params);

var label = labelForSubexpr(params, hash, helperName);
var helper = lookupHelper(helperName, scope.getSelf(), env);

Expand Down