-
I am currently working on formatting a JSON array using Mockoon's templating system, and I've encountered a challenge with the each helper, specifically regarding the placement of commas. When I use the repeat helper, it correctly adds a comma after each object in the array and omits the comma for the last object, as expected. Here's an example:
However, I'm trying to achieve a similar result with the each helper. When I use the each helper like this:
I don't get a comma after each object. But if I try to manually add a comma:
It results in an extra comma after the last object, making the JSON invalid. Is there a way in Mockoon's templating system to correctly place a comma after each object except the last, similar to how it works in the repeat helper? Any advice or example syntax for this would be greatly appreciated. Thank you for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The
|
Beta Was this translation helpful? Give feedback.
The
repeat
helper is a custom one we create that automatically add the comma. Theeach
is the one from Handlebars that is only iterating. To add a comma except on the last item, you can useunless
(also from Handlebars):