Loop Handling
Loop handling is used to repeatedly render data from arrays or objects by defining start and end markers for the loop. Below, several common scenarios are described.
Iterating over Arrays
1. Syntax Description
- Use the tag
{d.array[i].property}to define the current loop item, and use{d.array[i+1].property}to specify the next item to mark the loop area. - During the loop, the first line (the
[i]part) is automatically used as the template for repetition; you only need to write the loop example once in the template.
Example syntax format:
2. Example: Simple Array Loop
Data
Template
Result
3. Example: Nested Array Loop
Suitable for cases where an array contains nested arrays; nesting can be at an infinite level.
Data
Template
Result
4. Example: Bidirectional Loop (Advanced Feature, v4.8.0+)
Bidirectional loops allow iteration over both rows and columns simultaneously, which is suitable for generating comparison tables and other complex layouts (note: currently, some formats are officially supported only in DOCX, HTML, and MD templates).
Data
Template
Result
5. Example: Accessing Loop Iterator Values (v4.0.0+)
Within a loop, you can directly access the current iteration's index, which helps meet special formatting requirements.
Template Example
Note: The number of dots indicates the index level (for example,
.irepresents the current level, while..irepresents the previous level). There is currently an issue with reverse ordering; please refer to the official documentation for details.
Iterating over Objects
1. Syntax Description
- For properties in an object, use
.attto obtain the property name and.valto obtain the property value. - During iteration, each property item is traversed one by one.
Example syntax format:
2. Example: Object Property Iteration
Data
Template
Result
Sorting
Using the sorting feature, you can directly sort array data within the template.
1. Syntax Description: Ascending Order Sorting
- Use an attribute as the sorting criterion in the loop tag. The syntax format is:
- For multiple sorting criteria, separate the attributes with commas within the brackets.
2. Example: Sorting by Numeric Attribute
Data
Template
Result
3. Example: Multi-Attribute Sorting
Data
Template
Result
Filtering
Filtering is used to filter out rows in a loop based on specific conditions.
1. Syntax Description: Numeric Filtering
- Add conditions in the loop tag (for example,
age > 19). The syntax format is:
2. Example: Numeric Filtering
Data
Template
Result
3. Syntax Description: String Filtering
- Specify string conditions using single quotes. For example:
4. Example: String Filtering
Data
Template
Result
5. Syntax Description: Filter the First N Items
- You can use the loop index
ito filter out the first N elements. For example:
6. Example: Filtering the First Two Items
Data
Template
Result
7. Syntax Description: Exclude the Last N Items
- Use negative indexing
ito represent items from the end. For example:{d.array[i=-1].property}retrieves the last item.{d.array[i, i!=-1].property}excludes the last item.
8. Example: Excluding the Last One and Last Two Items
Data
Template
Result
Deduplication
1. Syntax Description
- Using a custom iterator, you can obtain unique (non-duplicate) items based on a property value. The syntax is similar to a normal loop but automatically ignores duplicate items.
Example format:

