Skip to content

Conformance Examples 0.1.0 — Transforms: transform-replace_last

replace_last-basic

Replaces only the last occurrence; earlier matches are untouched.

Template

{{ phrase | replace_last: "world" "Mark" }}

Context

{
    "phrase": "hello world, big world"
}

Output

hello world, big Mark

replace_last-target-absent

If target is not present, output equals input.

Template

{{ phrase | replace_last: "xyz" "abc" }}

Context

{
    "phrase": "hello world"
}

Output

hello world

replace_last-empty-target

Empty target inserts the replacement at the end of the input.

Template

{{ phrase | replace_last: "" "X" }}

Context

{
    "phrase": "abc"
}

Output

abcX

replace_last-chained-before-upcase

Pipes the result into a downstream transform.

Template

{{ phrase | replace_last: "world" "Mark" | upcase }}

Context

{
    "phrase": "hello world"
}

Output

HELLO MARK

Source fixture: transforms/transform-replace_last.json