Skip to content

Conformance Examples 0.1.0 — Transforms: transform-split

split-comma

Splitting on a comma yields a list rendered as a JSON-ish array of quoted strings.

Template

{{ csv | split: "," }}

Context

{
    "csv": "a,b,c"
}

Output

["a","b","c"]

split-delimiter-absent

If the delimiter is not in the input, the result is a single-element list.

Template

{{ phrase | split: "," }}

Context

{
    "phrase": "hello"
}

Output

["hello"]

split-empty-delimiter

Empty delimiter produces a list of single-character primitives.

Template

{{ phrase | split: "" }}

Context

{
    "phrase": "abc"
}

Output

["a","b","c"]

split-empty-input

Empty input split by any non-empty delimiter produces a list with one empty-string element.

Template

{{ phrase | split: "," }}

Context

{
    "phrase": ""
}

Output

[""]

split-empty-input-empty-delim

Empty input split by empty delimiter produces an empty list.

Template

{{ phrase | split: "" }}

Context

{
    "phrase": ""
}

Output

[]

split-piped-into-contains

Result list composes with contains: the array branch handles list inputs.

Template

{{ csv | split: "," | contains: "b" }}

Context

{
    "csv": "a,b,c"
}

Output

true

split-piped-into-each

Result list composes with each-block iteration.

Template

{{#each csv | split: "," }}{{ this }};{{/each}}

Context

{
    "csv": "x,y,z"
}

Output

x;y;z;

split-empty-delimiter-astral

Empty-delimiter split explodes by code point, so a surrogate pair stays one element rather than splitting into two.

Template

{{ s | split: "" }}

Context

{
    "s": "a😀b"
}

Output

["a","😀","b"]

Source fixture: transforms/transform-split.json