helpers / handlebars-helpers

188 handlebars helpers in ~20 categories. Can be used with Assemble, Ghost, YUI, express.js etc.
http://assemble.io/helpers/
MIT License
2.22k stars 365 forks source link

isLast in nested forEach #404

Open hafnerpw opened 2 years ago

hafnerpw commented 2 years ago

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 ?