assemble / assemble-handlebars

Assemble engine plugin for Handlebars templates
https://github.com/assemble/assemble
MIT License
8 stars 19 forks source link

{{@index}} inside {{#each}} messes with {{data}} #24

Open knight-dj-et opened 9 years ago

knight-dj-et commented 9 years ago

In my project, I have a .hbs similar to the following:

<div>
    <div id="description">
        {{data.description}}
    </div>
    <div id="operations">
        {{#each (getOperations page.basename)}}
             {{@index}}: {{this}}
        {{/each}}
    </div>
</div>

(This is somewhat simplified)

If the {{@index}} is included, then {{data.description}} (or anything else depending on data) doesn't render (because data seems to now hold a value if "true"). It seems to be related to how the index, etc are passed along in the each helper (in that, if I prevent that from actually occurring, everything works as it should).

I'm filing this here as opposed to with handlebars directly because the issue does not occur when I set up something like this in their jsFiddle template.

jonschlinkert commented 9 years ago

Hmm, that sounds like something that is more likely to happen in assemble than handlebars, since we have to merge context and other things that handlebars doesn't do natively.

we're working on releasing a new version of handlebars-helpers, so I'll try to add tests that address this specifically to see if I can find the cause. in the meantime if you're still working on this and would like to do a pr on the v0.6.0 branch to recreate the problem that would be great too.

(sorry for the late reply on this, for some reason sometimes I don't always seem to get notifications on things, or I accidentally mark them read... )

upstroke commented 9 years ago

Same happens when using YAML data referenced via '../'

{{ ../yamlvar.[@index] }}