express-handlebars icon indicating copy to clipboard operation
express-handlebars copied to clipboard

#each block ignored

Open GeeWizWow opened this issue 9 years ago • 2 comments

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 [email protected]

Thanks for your time

GeeWizWow avatar Dec 05 '15 21:12 GeeWizWow

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

rauberdaniel avatar Feb 03 '16 14:02 rauberdaniel

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.

jpike88 avatar Oct 17 '16 05:10 jpike88