Render a Comma-Separated List of Things in A Template File rename
author:
contributor:
published:
updated:
source uri:
Freebase Apps Help Topic /freebase/apps/help_topic
Status:
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.
> 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.
Recent Discussions about Render a Comma-Separated List of Things in A Template File
There is no discussion about this document.
Start the Discussion »