Templates

Repeaters

A repeater is a list of items edited in place: a team, an FAQ, the steps of a recipe. Each item has fields of its own.

A repeater is a list of items that belong to this page: a team, a set of questions and answers, the steps of a recipe. Editors add, move, duplicate and remove items right on the page, and each item has fields of its own.

<ul class="grid:cols-3-fr:gap-d6">
  {{ list:team }}
  <li class="col gap:d2">
    <img src="{{ photo:image }}" class="w:full aspect:square fit:cover">
    <h3 class="font:h5:semibold">{{ name:text:required }}</h3>
    <p class="text:ink-3">{{ role:text }}</p>
  </li>
  {{ /list }}
</ul>

Everything between {{ list:team }} and {{ /list }} is one item. It works like a small template: it can hold text, rich text, image and colour fields, conditions and references. The fields belong to each item, so “name” is a different name in every item.

A repeater can go in a page template or in a block. In a block, each copy of the block has its own items. The starter's Team, Features and menu blocks work this way, and Build a block adds one as List of items.

Repeaters or lists of pages

A list of pages shows other pages, each with an address of its own. A repeater holds small things that only make sense on this page and don't need an address. A team page with a short card per person is a repeater; a journal where each post has its own page is a list of pages.

Rules

  • The list needs an element to itself, like the <ul> above, with nothing else inside it. The editor puts new items there. Otherwise Verso stops with “{{ list:team }} needs an element to itself”.
  • Each item is exactly one element, like <li>…</li>, so it can be moved and removed as a whole. Two side by side stop with “Each item in {{ list:team }} needs exactly one outer element”.
  • A repeater can't go inside a list of pages or inside another repeater. Either stops with a message.
  • Its name is a field name, so it can't be the same as another field in the template.

In the editor

An empty repeater shows a dashed box that says “No team yet. Add the first one.” Click it to add the first item. Once there are items, hover or tap the list and an Add to Team button appears under it; new items go at the end. Items have the same handles as blocks, to move, duplicate or remove them, and their fields are edited in place like any other.

Where items are kept

Items are stored in the page's page.json, under "blocks", in the order they appear. Each item names the file and the list it belongs to, joined by two dashes: "about--team" for the team list in templates/about.html:

"blocks": {
  "team": [
    { "id": "b-3f9a1c", "block": "about--team", "fields": { "name": "Ada Wren", "role": "Editor", "photo": { "file": "ada.jpg", "alt": "Ada at her desk" } } },
    { "id": "b-8c21d0", "block": "about--team", "fields": { "name": "Lin Ho", "role": "Design" } }
  ]
}

In a block, the items are kept inside that block, under its own "blocks", and are named after the block: "team--people" for the people list in blocks/team.html.

{ "id": "b-10cf36", "block": "team", "fields": { "heading": "Who you'll work with" }, "blocks": {
  "people": [
    { "id": "b-4b8fc1", "block": "team--people", "fields": { "name": "Ada Moreno", "role": "Design lead" } }
  ]
} }

Images are kept in the page's own folder, like the page's other images.