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

Two nearly-identical if-blocks result in the first being used twice. #527

Closed
mnaughto opened this issue May 17, 2013 · 2 comments
Closed

Comments

@mnaughto
Copy link

I ran into a very strange issue working with handlebars that is best shown via code. This first snippet is the code which worked.

<div class="outer_thing">
    {{#if some_predicate}}
        {{#if some_inner.predicate}}
            <input type="text" class="left" autocorrect="off" autocapitalize="false" autocomplete="off" />
        {{else}}
            <div class="permanent left"></div>
        {{/if}}

        {{#foreach some_inner.collection}}
            <div class="permanent">{{value.thing}}</div>
        {{/foreach}}

        {{#if some_inner.predicate}}
            <input type="text" class="right" autocorrect="off" autocapitalize="false" autocomplete="off" />
        {{else}}
            <div class="permanent right"></div>
        {{/if}}
    {{else}}
        _

        {{#foreach some_inner.collection}}
            <div class="permanent">{{value.thing}}</div>
        {{/foreach}}

        _
    {{/if}}
</div>

This second snippet of code erroneously produced two inputs or divs with class "left", when logically, the output should have been the same as above.

<div class="outer_thing">
    {{#if some_predicate}}
        {{#if some_inner.predicate}}
            <input type="text" class="left" autocorrect="off" autocapitalize="false" autocomplete="off" />
        {{else}}
            <div class="permanent left"></div>
        {{/if}}
    {{else}}
        _
    {{/if}}

    {{#foreach some_inner.collection}}
        <div class="permanent">{{value.thing}}</div>
    {{/foreach}}

    {{#if some_predicate}}
        {{#if some_inner.predicate}}
            <input type="text" class="right" autocorrect="off" autocapitalize="false" autocomplete="off" />
        {{else}}
            <div class="permanent right"></div>
        {{/if}}
    {{else}}
        _
    {{/if}}
</div>

The first would result in:

<input type="text" class="left" autocorrect="off" autocapitalize="false" autocomplete="off"/>
<div class="permanent">...</div>
<div class="permanent">...</div>
<input type="text" class="right" autocorrect="off" autocapitalize="false" autocomplete="off"/>

And the second would result in the following (note that both input elements have the class "left"):

<input type="text" class="left" autocorrect="off" autocapitalize="false" autocomplete="off"/>
<div class="permanent">...</div>
<div class="permanent">...</div>
<input type="text" class="left" autocorrect="off" autocapitalize="false" autocomplete="off"/>

This result was obtained with version 1.0.0 RC3.

@stefanpenner
Copy link
Collaborator

this is a known issue with handlebars RC3, but it should is fixed in handlebars RC4. If you can quickly confirm that would be lovely, and If the issue persists I will gladly reopen at that time gladly reopen.

See #428 for more details.

@mnaughto
Copy link
Author

Yep, #428 looks like the problem we were having. Thanks

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