say have following json:
category: { a_items: [], b_items: [] }
and have handlebars partial:
{{#each items}} {{stuff}} {{/each}}
what tell partial array iterate over:
{{> showitems items=a_items}}
however, partial try iterate on category.items
doesn't exist.
so possible without having create helper?
p.s. this answer suggest not can't work out helper do. don't want move entire {{stuff}}
section of partial helper.
here's solution found. create helper:
handlebars.registerhelper('returnkeyvalue', function(obj, key, options) { return options.fn(obj[key]); });
pass context helper:
{{#returnkeyvalue items}} {{> partialthatiteratesoveritems}} {{/returnkeyvalue}}
which call 2 different contexts:
{{> partial items='a_items'}} {{> partial items='b_items'}}
Comments
Post a Comment