Skip to content

Custom helper each with comma #1239

Closed Answered by 255kb
jcbenck asked this question in Help
Discussion options

You must be logged in to vote

The repeat helper is a custom one we create that automatically add the comma. The each is the one from Handlebars that is only iterating. To add a comma except on the last item, you can use unless (also from Handlebars):

[
  {{#each (dataRaw 'abcd')}}
    {
      "name": "{{this.name}}"
    }{{#unless @last}},{{/unless}}
  {{/each}}
]

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jcbenck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants