json - Handlebars each helper arguments -
i trying include object in {{each}} iteration in handlebars doesn't belong actual array object.
- myarrayobj <-- array of json objects include bunch of fields
- someotherobj <-- json object includes bunch of fields
first attempt:
{{#each myarrayobj}} {{#myhelper this.fieldinarrayobject someotherobj.somefield}} {{/myhelper}} {{/each}}
helper:
handlebars.registerhelper('myhelper', function (date, language) { console.log(json.stringify(language)); // <--- language undefined });
someotherobj.somefield coming out undefined in helper class? else working.
another example:
{{something.field}} // <--- works, displays wish {{#each sessions}} {{something.field}} // <--- not work {{/each}}
when using object not belong current scope, you'll need use path
try this
{{#each myarrayobj}} {{#myhelper this.fieldinarrayobject ../someotherobj.somefield}} {{/myhelper}} {{/each}}
for more on using paths - @ handlebars paths on handlebarsjs.com
Comments
Post a Comment