josh/mustache-rails — pull request #7 by dasch (2012-06-15 11:17:26+00:00)
Title: Template shadowing

Sorry to be at it again, but I've run into what seems to be a weird bug.

If I have nested loops, like this:

```mustache
{{! app/templates/categories/index.mustache }}
{{#categories}}

{{title}}

{{#topics}}

{{title}}

{{/topics}}
{{/categories}}
```

Then only the first category's title will be in `

`, while the rest will be in `

`. It seems that the inner template is "shadowing" the outer one. If I write the template like this:

```mustache
{{! app/templates/categories/_topic.mustache }}

{{title}}

{{! app/templates/categories/index.mustache }}
{{#categories}}

{{title}}

{{#topics}}
{{>topic}}
{{/topics}}
{{/categories}}
```

... I'll get the expected behavior.

I've attached a failing test demonstrating the problem. I may just be doing something wrong again, though, in which case I apologize for the trouble in advance :-)