Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bardachov opened this issue Mar 30, 2018 · 3 comments
Open

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

bardachov opened this issue Mar 30, 2018 · 3 comments

Comments

@bardachov
Copy link

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
Copy link

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
Copy link
Member

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

@iamtabrezkhan
Copy link

Hi @jonschlinkert

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants