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

Nested if else rendering problem #428

Closed
kavu opened this issue Feb 5, 2013 · 2 comments
Closed

Nested if else rendering problem #428

kavu opened this issue Feb 5, 2013 · 2 comments
Assignees
Labels

Comments

@kavu
Copy link

kavu commented Feb 5, 2013

Here is the example: http://jsfiddle.net/Wtw2Z/1/

What I got there?

Here is the template (I extracted it from my project a simplified and bit):

{{#if order}}
  {{#if id}}
a1
  {{else}}
a2
  {{/if}}
{{else}}
a3
{{/if}}

{{#if text}}
  b1
{{else}}
  {{#if id}}
    b2
  {{else}}
    b3
  {{/if}}
{{/if}}     

Using handlebars.js from 448e43c I expected to get some sort of a3 b3 but I got a3 a2. It was really confusing when I got it first time, so I began to investigate.

I came to this:

Rename id to something else:

{{#if order}}
  {{#if _id}}
a1

Remove 1 indentation space before {{#if _id}}:

{{#if order}}
 {{#if _id}}
a1

With this two "hacks" I got proper, expected result (see console.log output in the provided JSFiddle example). Weird.

Maybe there is logical mistake in my code and I shouldn't use this clumsy construction, but that 1 space looks like a parser bug for me.

Thanks!

@devwout
Copy link

devwout commented Feb 6, 2013

I also encountered a problem, which is probably related to this issue. Failing example on http://pastie.org/6077920

@kpdecker
Copy link
Collaborator

It looks like this (or at least @devwout's issue) was caused by b661977

This is erroneously marking sub programs as duplicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants