Open scurker opened 4 years ago
@scurker thanks for detailing the problem as I stumbled the same issue as you describe here and wasn't able to debug it. using this.url
worked the best, since I'm using several partials within the each
loop, naming the iterator would cause me some problems.
I'd also agree, perhaps have a note/hint in the documentation would be good!
Describe the bug
Using handlebars' built in
#each
helper and a collection's url can throw aTypeError: url.indexOf is not a function
.To Reproduce
Display a collection of items with handlebars
#each
:Expected behavior
No error.
Environment:
0.10.0
Additional context
What I think is happening is that handlebars is remapping object keys inside of the helper, so
{{url}}
inside of#each
actually looks something like:...which when passed through 11ty's url filter does not have
indexOf
.There's a simple workaround for this though by referencing the original object with
this.url
instead:Alternatively, naming the iterated value should work as well:
Perhaps this method should be documented for handlebars?