helpers / handlebars-helpers

188 handlebars helpers in ~20 categories. Can be used with Assemble, Ghost, YUI, express.js etc.
http://assemble.io/helpers/
MIT License
2.21k stars 365 forks source link

forEach doesn't work if array item is null #313

Open bardachov opened 6 years ago

bardachov commented 6 years ago

I use helper in this way {{# forEach allergens }} {{ tag }}{{# unless isLast }},{{/ unless }} {{/ forEach }}

but if allergens = [{tag:32}, null] I got an error Cannot set property 'index' of null line

shanemac10 commented 4 years ago

Please see my open issue with BigCommerce Stencil-CLI, as this is causing server 500 errors and is any easy fix.

Thanks!

My local fix was to add an empty array as a default parameter, but you may choose to do a fast-fail... helpers.forEach = function(array=[], options) {

jonschlinkert commented 4 years ago

Good catch... Since null won't cause the default to be used. Want to do a PR?

iamtabrezkhan commented 4 years ago

Hi @jonschlinkert

Is this still open? I would be glad to do a PR to fix this.