Render a Comma-Separated List of Things in A Template File rename

author:

contributor:

published:

updated:

source uri:

Summary

Say you have an array of things and you want to render them (into HTML from within a template file)...

Content

Say you have an array of things and you want to render them (into HTML from within a template file) as a comma-separated list:

> 1, 2, 3, 4

and you're super-picky about where the commas go. You don't want any space between a comma and its preceding item, and you don't want a comma after the last item. The trick here is to test the index of each item and not generate a comma for the first item:

>
> 0">,
> $v
>

The `trim` attribute makes sure that Acre eliminates undesirable spaces.

Created by: dfhuynh via Cookbook Jun 4, 2009
Last edited by: dfhuynh via Cookbook Jul 9, 2009

Recent Discussions about Render a Comma-Separated List of Things in A Template File

There is no discussion about this document.

Start the Discussion »
Explore the Data
View all the data we have for Render a Comma-Separated List of Things in A Template File
Flag this Document
Why do you want to flag this document?