Reputation: 896
I'm trying to iterate through a JSON Array as shown below using a handle bar code.
JSON array:
[{"email":"[email protected]","repo":"https://github.com"},{"email":"[email protected]","repo":"https://github.com"},{"email":"[email protected]","repo":"https://github.com"}]
Handle bar code:
{{#each ["abc"].[json]}}
EMAIL:{{["abc"].[json].[@index].[email]}}
REPO:{{["abc"].[json].[@index].[repo]}}
{{#if @last }}
Last entry!
{{/if}}
{{/each}}
where ["abc"].[json].[0...100].email/repo is the output Json array from a previous process. With the code above I'm not getting the required result and the output are empty strings, any help is much appreciated.
Required OUTPUT:
EMAIL:[email protected]
REPO:https://github.com
EMAIL:[email protected]
REPO:https://github.com
Upvotes: 1
Views: 121
Reputation: 3559
Inside the #each
helper the context switch to the current element, similar as in a forEach method in JS:
{{#each ["abc"].[json]}}
EMAIL:{{email}}
REPO:{{repo}}
{{#if @last }}
Last entry!
{{/if}}
{{/each}}
Upvotes: 1