ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 382 forks source link

#each block ignored #156

Open GeeWizWow opened 8 years ago

GeeWizWow commented 8 years ago

Hi

I'm having an issue with the each block being ignored at render

as per the example here: http://handlebarsjs.com/builtin_helpers.html

res.render('home',{
            helpers: {
                people: [
                    "Yehuda Katz",
                    "Alan Johnson",
                    "Charles Jolley"
                ]
            }
        });

<ul>
<li>Test</li>
{{#each people}}
    <li>{{this}}</li>
{{/each}}
</ul>

Renders this:

<ul>
<li>Test</li>
</ul>

Using express-handlebars@2.0.1

Thanks for your time

rauberdaniel commented 8 years ago

you should either do {{#each helpers.people}} or move the people property outside the helpers object.

jpike88 commented 7 years ago

This drove me almost INSANE trying to resolve, I spent too much time looking into handlebars documentation to then come back and find this issue.

You should be having anything defined in 'helpers' bubble upwards automatically as this is not how handlebars normally works.