Handlebars looping through getters
Hello,
I'm trying to loop through and objects property including its getter, but since Handlebars 4.6.0 this is not allowed unless
allowedProtoMethods
is set to true
(https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access). How/where can I set that option?
For context I have a nested object to represent ability scores and accessing deeper sub stats with getters, and to list out the ability scores I'm looping through them. I can always output them each individually, but have a loop to do this would be ideal.3 Replies
Seems like you cannot pass options to
renderTemplate
itself, but it looks like you could easily make your own version and pass whatever options you want 😉
However, it also seems like something called allowProtoMethodsByDefault
is set to true
so it should work for you by default if I understand the docs you linked 🤔
I'm not that good with hbs, so that's about the extent of what I knowhmmm interesting, maybe the
{{#each}}
doesn't loop through getters? Thanks for the info, ill look into this more. If you don't mind could you send me where u got that screenshot from? @Forienfoundry.js@7741
, but it's best to just follow linking in your IDE if it supports it. Or just ctrl+f and search for the function's signature