-
Notifications
You must be signed in to change notification settings - Fork 19
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
"each" helper throws "TypeError: ret.join is not a function" when the context is an empty list #9
Comments
toverux
changed the title
TypeError: ret.join is not a function
"each" helper throws "TypeError: ret.join is not a function" when the context is an empty list
Oct 20, 2022
evertonrobertoauler
added a commit
to evertonrobertoauler/handlebars-async-helpers
that referenced
this issue
Jan 16, 2023
Open
ericalli
added a commit
to ericalli/handlebars-async-helpers
that referenced
this issue
May 13, 2023
I submitted PR #15 with the aforementioned fix and tests. |
tobnieder
added a commit
to tobnieder/handlebars-async-helpers
that referenced
this issue
Aug 29, 2023
Fixing issue gastonrobledo#9 with tests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This error appears to happen when empty sources are passed to the each helper that is overriden by this library.
It's this line that crashes :
handlebars-async-helpers/helpers/each.js
Line 108 in cc6ad44
The problem is that when the items count is 0, options.inverse() is called on the context and replaces the return value.
But by default, when each has no else condition, it's a noop that does not return an array but an empty string, making ret.join() crash.
Handlebars does not have this problem because they don't have to join : https://github.com/handlebars-lang/handlebars.js/blob/785a63e0a84bc5d6617fd1619baa975f1380ddbd/lib/handlebars/helpers/each.js#L80
This solution works, for example:
The text was updated successfully, but these errors were encountered: