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

Extremely odd behavior with nested {{#if}} helpers #2663

Closed
workmanw opened this issue May 13, 2013 · 3 comments
Closed

Extremely odd behavior with nested {{#if}} helpers #2663

workmanw opened this issue May 13, 2013 · 3 comments

Comments

@workmanw
Copy link

We discovered a really bizarre issue today when using nested {{#if}} helpers that have a common condition. It seems that when two {{#if}} helpers have different conditions, but have a common nested condition, it causes a very unexpected rendering.

Example:

{{#if myCondition1}}
  {{#if showInnerSection}}
    Hello 1
  {{/if}}
{{/if}}
{{#if myCondition2}}
  {{#if showInnerSection}}
    Hello 2
  {{/if}}
{{/if}}

If you assume that all three of the above conditions are true (myCondition1, myCondition2 and showInnerSection are all true), the value should be: "Hello 1 Hello 2". However: with RC3 it is: "Hello 1 Hello 1". See this Fiddle: http://jsfiddle.net/DCrHG/15/

So by now you might be thinking, uh, WTF. Here is where I completely blow your mind, if you add a carriage return (newline) in between the nested statements, it WORKS as expected. See this Fiddle: http://jsfiddle.net/DCrHG/16/

Our app is currently on RC2. This problem exists on RC3 in a fiddle. Unfortunately, I can't say for sure how long this has been a problem. We just noticed it today.

CC: @jkoehl

@lukemelia
Copy link
Member

I think this is a handlebars bug that was recently fixed: handlebars-lang/handlebars.js#514 / handlebars-lang/handlebars.js#428

Can you try it with latest handlebars and reopen if that does not fix the problem?

@workmanw
Copy link
Author

Yea, I'd love to test and confirm, but it seems that the Handlebars.COMPILER_REVISION revision was changed to 3 (baccdb4c) before this was fixed (d6f146f). Ember-latest currently only supports compiler revision 2. Any advice on how to actually test it?

@lukemelia
Copy link
Member

@workmanw ideally, you could add a failing test case, update to COMPILER_REVISION to 3 and pull in the new handlebars, verify that that fixes the problem, and then submit a PR with those changes.

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

2 participants