Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handlebars #each for object or array

I am having an issue where sometimes the object I want to iterate through is just a plain object but sometimes it's an array, for both I am using the {{#each}} Handlebars built-in helper.

When the object is an array, it works just fine, but when it is a plain object it is not working. How can I get around that?

Thanks!

like image 414
joe_cqr Avatar asked Jan 17 '26 20:01

joe_cqr


1 Answers

when iterating over properties {{@key}} refers to property name, and {{this}} refers to property value

more here https://handlebarsjs.com/guide/builtin-helpers.html#each

like image 191
djaszczurowski Avatar answered Jan 21 '26 08:01

djaszczurowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!