---
title: "web for each · RUAL Documentation"
description: "Repeats a row template for every item of a list, e.g. the rows of a table. Every row is keyed, so a web action can later replace or remove exactly that…"
canonical: https://docs.rual.nl/block-types/web/web_foreach
language: en
---

# web for each

This block is part of the [`web`](https://docs.rual.nl/block-types/web) group and was last modified in core [`v15.0.1`](https://docs.rual.nl/core-versions/150001).

Repeats a row template for every item of a list, e.g. the rows of a table. Every row is keyed, so a web action can later replace or remove exactly that row.

- items `array` required The list to render, e.g. the documents of a storage search.

- row template `value` The template of one row; the item's fields are its variables.

- key field `value` The item field that identifies a row (default _meta.guid, then id).

- empty template `value` Rendered instead when there are no items.

- data `object` Variables every row can read too.

- html `value`

- count `number`

- success `condition`

- error `value`

Data block (no flow pins): renders `template` (or the block's stored `html` field) once per element of `items`, in order, and outputs the rows joined as html, plus count. A row's context is the item (its fields by name), with the `data` object, the custom pins and `web` visible behind it, and {{@index}} {{@number}} {{@first}} {{@last}}. Each row's first element gets data-key=<key>: the item field named by `key` (a dotted path), else _meta.guid, guid, id or key, else the row's index; a row whose root already has data-key keeps its own. Empty or non-list items: renders `empty` (a template, with the shared data) or "", count 0. Put the html into the page with {{{rows}}} (triple braces: it is already escaped markup). Error: html="", success=false, error set.

| `datatable` |
| --- |
| `table rows` |
| `list` |
| `repeat` |
| `loop template` |

[search](https://docs.rual.nl/block-types/storage/function_search) runs in the page's flow and its array feeds [web for each](https://docs.rual.nl/block-types/web/web_foreach), which renders the row template once per document and gives every row a data-key, so a later action can replace or remove exactly that row. It has no flow pins: it runs when something reads its html. Here that is a custom pin of [web render](https://docs.rual.nl/block-types/web/web_render), printed in the page template with triple braces, `{{{rows}}}`, and count goes to a second one. The empty pin is the template for a list with no items.

[![Studio canvas example for the web for each block: a table of search results.](https://docs.rual.nl/canvas-examples/web_foreach.png)](https://docs.rual.nl/canvas-examples/web_foreach.png?v=3)

## Used in these guides

These documentation pages use or explain this block:

- [Building a Dashboard with Charts](https://docs.rual.nl/tutorials/dashboard-charts)

- [Building with AI](https://docs.rual.nl/web/with-ai)

- [Common Blueprint Patterns](https://docs.rual.nl/blueprints/common-patterns)

- [Escaping and Security](https://docs.rual.nl/web/security)

- [Layouts and Partials](https://docs.rual.nl/web/layouts-and-partials)

- [Lists and Tables](https://docs.rual.nl/web/lists)

- [Markup Reference](https://docs.rual.nl/web/markup)

- [Migrating from State Pages](https://docs.rual.nl/web/migrate-from-state-pages)

## Version history

Introduced in [`v15.0.1`](https://docs.rual.nl/core-versions/150001).

- [`v15.0.1`](https://docs.rual.nl/core-versions/150001): block added in this release.

- [Back to `web`](https://docs.rual.nl/block-types/web): Return to the main group to view all sub-groups

- [Back to `web templates`](https://docs.rual.nl/block-types/web?group=web%20templates): Return to the group to view all blocks within this group
