Looping through array data

Repeating data, from an array of data, can be displayed in many ways.

This example contains: each item on a new line, each item on the same line, bullet lists, and numbered lists.

Defining a repeating section

A repeating section starts with <<rs_ and finishes with <<es_ (end section).

This example uses a list of people: <<rs_people>>...<<es_people>>

In your data you would have an array of objects like this (JSON example):

    "people":[{"name":"John"}, ... ]  (JSON example).

So, <<rs_people>><<name>><<es_people>>, is like saying:

FOR all people LOOP

replace each <<name>> with data up to <<es_people>>

If <<rs_ or <<es_ appear on a line by themselves, then that line does not appear in the final document.

Displaying items over one or many lines

The first repeating section in the template lists one item per line, because in the template <<name>> appears on a line by itself.

The second example in the template shows how to list all of the names in a single line. To achieve this, the opening <<rs_ directive, the <<name>> field and the closing <<es_ directive are all on the same line.  The field <<name>> is followed by a space, to provide a space between each name in the list.

Numbered lists and bullet lists

The template also contains two lists. 

The first is a numbered list, where the line containing <<name>> is formatted as a numbered list item.

The second is a bullet list, where the line containing <<name>> is formatted as a bullet point.

Each list grows to match the items in the data.

TemplateTutorials

Feedback

Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam. Please also consider contacting support@docmosis.com if you need help with this article.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input