# Conditional behavior in template if last array item was found

**URL:** <https://discourse.gohugo.io/t/conditional-behavior-in-template-if-last-array-item-was-found/1270>\
**Category:** support\
**Created:** [June 5, 2015, 11:28am UTC](https://discourse.gohugo.io/t/conditional-behavior-in-template-if-last-array-item-was-found/1270 "2015-06-05T11:28:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![digitalcraftsman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/digitalcraftsman/32/4142_2.png) [@digitalcraftsman](https://discourse.gohugo.io/u/digitalcraftsman)\
**Post date:** [June 5, 2015, 11:28am UTC](https://discourse.gohugo.io/t/conditional-behavior-in-template-if-last-array-item-was-found/1270/1 "2015-06-05T11:28:47Z")

</div>

I’m storing an address as an array in my config file. I’m interating over the array to render put each index on it’s own line by appending the HTML with an   
 tag. The problem is, that the   
 after the last index is unnecessary.

To prevent this I only want to add an   
 of the item is not the last one of the array.

My current template looks like this:

```auto
<p>
    {{ range .Site.Params.address }}
        {{ . }}<br>
    {{ end }}
</p>

```

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 5, 2015, 12:10pm UTC](https://discourse.gohugo.io/t/conditional-behavior-in-template-if-last-array-item-was-found/1270/2 "2015-06-05T12:10:12Z")

</div>

> **[Howto: Delimiter separated tags](https://discourse.gohugo.io/t/howto-delimiter-separated-tags/146)**
>
> The construction below looks counter-intuitive, but it works: Given: Tags = \['item1', 'item2', 'item3'\] This: {{ range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} Gives: item1, item2, item3 The example above uses tags...

---

<div class="post-metadata">

**Author:** ![digitalcraftsman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/digitalcraftsman/32/4142_2.png) [@digitalcraftsman](https://discourse.gohugo.io/u/digitalcraftsman)\
**Post date:** [June 5, 2015, 12:52pm UTC](https://discourse.gohugo.io/t/conditional-behavior-in-template-if-last-array-item-was-found/1270/3 "2015-06-05T12:52:05Z")

</div>

That works nice, Thanks.
