Forum
JSON loop using repeaters
I want to create a JSON loop using repeaters. I can get most of the way but can't figure out how to leave off a comma-separator for the last items.
For example:
<perch:repeater id="images" label="Images" scope-parent="true">
<perch:every nth-child="1">
<img src="<perch:content type="image" id="image" label="Image" />" alt="<perch:content type="text" id="image_alt" label="Supporting text" />" />
<script class="other-slides" type="text/cycle">
[
<perch:else />
"<img src='<perch:content type="image" id="image" label="Image" />' alt='<perch:content type="text" id="image_alt" label="Supporting text" />' />",
<perch:after>
]
</script>
</perch:after>
</perch:every>
</perch:repeater>
With the trailing comma on the last entry the entry is invalidated.
Any thoughts appreciated …
Marvellous, worked. Thanks Drew!