logologo
Get Started
Guide
Development
Plugins
API
English
简体中文
Get Started
Guide
Development
Plugins
API
English
简体中文
logologo
Overview
Configuration

Template Syntax

Basic Usage
Loop Processing

Formatters

Overview
Text Formatting
Number Formatting
Currency Formatting
Date Formatting
Time Interval Formatting
Array Formatting

Advanced Features

Conditional Statements
Advanced Features
FAQ
Application Scenarios
Previous PageTime Interval Formatting
Next PageConditional Statements

#Array Formatting

#1. :arrayJoin(separator, index, count)

#Syntax Explanation

Joins an array of strings or numbers into a single string.
Parameters:

  • separator: The delimiter (default is a comma ,).
  • index: Optional; the starting index from which to join.
  • count: Optional; the number of items to join starting from index (can be negative to count from the end).
#Example
['homer','bart','lisa']:arrayJoin()              // Outputs "homer, bart, lisa"
['homer','bart','lisa']:arrayJoin(' | ')          // Outputs "homer | bart | lisa"
['homer','bart','lisa']:arrayJoin('')              // Outputs "homerbartlisa"
[10,50]:arrayJoin()                               // Outputs "10, 50"
[]:arrayJoin()                                    // Outputs ""
null:arrayJoin()                                  // Outputs null
{}:arrayJoin()                                    // Outputs {}
20:arrayJoin()                                    // Outputs 20
undefined:arrayJoin()                             // Outputs undefined
['homer','bart','lisa']:arrayJoin('', 1)          // Outputs "bartlisa"
['homer','bart','lisa']:arrayJoin('', 1, 1)       // Outputs "bart"
['homer','bart','lisa']:arrayJoin('', 1, 2)       // Outputs "bartlisa"
['homer','bart','lisa']:arrayJoin('', 0, -1)      // Outputs "homerbart"
#Result

The output is a string created by joining the array elements according to the specified parameters.

#2. :arrayMap(objSeparator, attSeparator, attributes)

#Syntax Explanation

Transforms an array of objects into a string. It does not process nested objects or arrays.
Parameters:

  • objSeparator: The separator between objects (default is , ).
  • attSeparator: The separator between object attributes (default is :).
  • attributes: Optional; a list of object attributes to output.
#Example
[{'id':2,'name':'homer'},{'id':3,'name':'bart'}]:arrayMap()
// Outputs "2:homer, 3:bart"

[{'id':2,'name':'homer'},{'id':3,'name':'bart'}]:arrayMap(' - ')
// Outputs "2:homer - 3:bart"

[{'id':2,'name':'homer'},{'id':3,'name':'bart'}]:arrayMap(' ; ', '|')
// Outputs "2|homer ; 3|bart"

[{'id':2,'name':'homer'},{'id':3,'name':'bart'}]:arrayMap(' ; ', '|', 'id')
// Outputs "2 ; 3"

[{'id':2,'name':'homer','obj':{'id':20},'arr':[12,23]}]:arrayMap()
// Outputs "2:homer"

['homer','bart','lisa']:arrayMap()    // Outputs "homer, bart, lisa"
[10,50]:arrayMap()                    // Outputs "10, 50"
[]:arrayMap()                         // Outputs ""
null:arrayMap()                       // Outputs null
{}:arrayMap()                         // Outputs {}
20:arrayMap()                         // Outputs 20
undefined:arrayMap()                  // Outputs undefined
#Result

The output is a string generated by mapping and joining the array elements, ignoring nested object content.

#3. :count(start)

#Syntax Explanation

Counts the row number in an array and outputs the current row number.
For example:

{d[i].id:count()}

Regardless of the value of id, it outputs the current row count.
Starting from v4.0.0, this formatter has been replaced internally by :cumCount.

Parameter:

  • start: Optional; the starting value for the count.
#Example and Result

In use, the output will display the row number according to the sequence of the array elements.