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

Using if in partials does not work as expected #705

Closed
dsst95 opened this issue Oct 13, 2017 · 0 comments
Closed

Using if in partials does not work as expected #705

dsst95 opened this issue Oct 13, 2017 · 0 comments

Comments

@dsst95
Copy link

dsst95 commented Oct 13, 2017

Related Issues

Steps to reproduce

When you use a {{#if valueOfParentContext}} statement in a partial the value gets undefined.

For example:

// main.hbs
{{#with 'Dennis' as |myAuthor|}}
  {{ partial 'foo' }}
{{/with}}
// foo.hbs
{{#if myAuthor}}
  Author: {{ myAuthor }}!
{{else}}
  No author!
{{/if}}

Expected result

The rendered Template should be Author: Dennis!.

Actual result

The rendered Template is No author!.

Comments

I've added a failing test.

tomdale added a commit that referenced this issue Oct 13, 2017
…biguous cases

MustacheExpressions generate a `get` opcode in cases where the identifier is statically found in their scope, but fall back to `maybeLocal` otherwise to disambiguate at compile time whether they are being invoked inside a partial or not.

PathExpressions however did not go through this path, always using a `get` opcode even in cases that were ambiguous. This caused any PathExpression inside a partial to fail when inheriting an identifier from the outside scope.

This commit changes the PathExpression compiler to generate a `maybeLocal` opcode in the ambiguous case instead of a `get`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant