Skip to content

Conformance Examples 0.1.0 — Transforms: transform-remove_last

remove_last-basic

Removes only the last occurrence; earlier matches are untouched.

Template

{{ phrase | remove_last: "o" }}

Context

{
    "phrase": "foo boo"
}

Output

foo bo

remove_last-target-absent

If the substring is absent, output equals input.

Template

{{ phrase | remove_last: "xyz" }}

Context

{
    "phrase": "hello world"
}

Output

hello world

remove_last-empty-arg

Removing an empty string leaves the input unchanged.

Template

{{ phrase | remove_last: "" }}

Context

{
    "phrase": "hello"
}

Output

hello

remove_last-chained-after-upcase

Composes correctly when input arrives from a prior transform.

Template

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

Context

{
    "phrase": "hello"
}

Output

HELO

Source fixture: transforms/transform-remove_last.json