> For the complete documentation index, see [llms.txt](https://coldbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coldbox.ortusbooks.com/v5.x-1/the-basics/layouts-and-views/views/rendering-collections.md).

# Rendering Collections

You have a few arguments in the `renderView()` method that deal with collection rendering. Meaning you can pass any array or query and the Renderer will iterate over that collection and render out the view as many times as the records in the colleciton.

* `collection` : A data collection that can be a query or an array of objects, structs or whatever
* `collectionAs` : The name of the variable in the variables scope that will hold the collection pivot.
* `collectionStartRow` : Defaults to 1 or your offset row for the collection rendering
* `collectionMaxRows` : Defaults to show all rows or you can cap the rendering display
* `collectionDelim` : An optional delimiter to use to separate the collection renderings. By default it is empty.

Once you call `renderView()` with a collection, the renderer will render the view once for each member in the collection. The views have access to the collection via arguments.collection or the member currently iterating. The name of the member being iterated as is by convention the same name as the view. So if we do this in any layout or simple view:

```javascript
#renderView(view='tags/comment',collection=rc.comments)#
```

Then the `tags/comment` will be rendered as many times as the collection `rc.comments` has members on it and by convention the name of the variable is comment the same as the view name.

```javascript
<h1>Title: #comment.Title# (#_counter# of #_items#</h1>
<p>Author: #comment.Author#</p>
#comment.Comment#
<hr/>
```

If you don't like that, then use the collectionAs argument:

```javascript
#renderView(view='tags/comment',collection=rc.comments,collectionAs='MyComment')#
```

So let's see the collection view now:

```javascript
<h1>Title: #MyComment.Title# (#_counter# of #_items#</h1>
<p>Author: #MyComment.Author#</p>
#MyComment.Comment#
<hr/>
```

You can see that I just call methods on the member as if I was looping (which we are for you). But you will also see two little variables here:

* `_counter` : A variable created for you that tells you in which record we are currently looping on
* `_items` : A variable created for you that tells you how many records exist in the collection

This will then render that specific dynamic HTML view as many times as their are records in the rc.comments array and concatenate them all for you. In my case, I separate each iteration with a simple   but you can get fancy and creative.

```javascript
#renderView(view="home/news", collection=prc.news, collectionStartRow=11, collectionMaxRows=20)#
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://coldbox.ortusbooks.com/v5.x-1/the-basics/layouts-and-views/views/rendering-collections.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
