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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -