helpers/handlebars-helpers

isLast in nested forEach

hafnerpw opened this issue · 0 comments

Hi, I can't make {{#unless isLast}} work inside a nested foreach. Here is what I'm trying:

{ "release": "{{releaseDetails.releaseDefinition.name}}", "release_number": "{{releaseDetails.name}}", "date": "{{releaseDetails.modifiedOn}}", "workItems": [ {{#forEach this.workItems}} { "id": "{{this.id}}", "title": "{{lookup this.fields 'System.Title'}}", "type": "{{lookup this.fields 'System.WorkItemType'}}", "tags": "{{lookup this.fields 'System.Tags'}}", "pullRequests": [ {{#forEach this.relations}} {{#if (contains this.attributes.name 'Pull Request')}} {{#with (lookup_a_pullrequest ../../pullRequests this.url)}} { "id": "{{this.pullRequestId}}", "title": "{{this.title}}", "description": {{{json (lookup this 'description')}}}, "closedDate": "{{this.closedDate}}", "labels" : {{{json this.labels}}} }{{#unless ../../isLast}}, {{/unless}} {{/with}} {{/if}} {{/forEach}} ] }{{#unless isLast}}, {{/unless}} {{/forEach}} ] }

Ii believe it is only checking the outter forEach because the last WorkItem also does not have a comma. Am I doing something wrong ?