Docly Developers
Function Updated 17 Oct 2026

String.split([separator], [limit])

Splits a single string into an array of strings based on the specified separator.

In template mode there is also an older global helper split(text) — a function, not a method — which splits by line breaks and drops empty lines.

Parameters

separatorstring | RegExpoptional

Text or regular expression to split the string by. Empty text splits into single characters. Without a separator, the whole string is returned as the only item.

limitnumberoptional

Maximum number of items to return. 0 returns an empty array.

Returns

An array of strings.

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
    var text = "1,2,3,4,5,6,7";
    
    /* Split text by comma */
    var array = text.split(",");
    
    for(let item of array)
    {
}#
<div>#item#</div>        
#}#