Skip to content

Conformance Examples 0.1.0 — Transforms: transform-remove_first

remove_first-basic

Removes only the first occurrence; later matches are untouched.

Template

{{ phrase | remove_first: "o" }}

Context

{
    "phrase": "foo boo"
}

Output

fo boo

remove_first-target-absent

If the substring is absent, output equals input.

Template

{{ phrase | remove_first: "xyz" }}

Context

{
    "phrase": "hello world"
}

Output

hello world

remove_first-empty-arg

Removing an empty string leaves the input unchanged.

Template

{{ phrase | remove_first: "" }}

Context

{
    "phrase": "hello"
}

Output

hello

remove_first-chained-after-upcase

Composes correctly when input arrives from a prior transform.

Template

{{ phrase | upcase | remove_first: "L" }}

Context

{
    "phrase": "hello"
}

Output

HELO

Source fixture: transforms/transform-remove_first.json