Skip to content

Conformance Examples 0.1.0 — Render: parent-pointer

parent-pointer-basic

{{ ../key }} inside a with block resolves against the parent context (one level up the stack).

Template

{{#with user }}{{ ../version }}{{/with}}

Context

{
    "version": "1.0",
    "user": {
        "name": "Alice"
    }
}

Output

1.0

parent-pointer-nested-path

A multi-segment RFC 6901 pointer after ../ resolves at the parent level.

Template

{{#with user }}{{ ../config/theme }}{{/with}}

Context

{
    "config": {
        "theme": "dark"
    },
    "user": {
        "name": "Alice"
    }
}

Output

dark

parent-pointer-two-levels-up

../../key ascends two stack levels, reaching the root context from inside two nested with blocks.

Template

{{#with a }}{{#with b }}{{ ../../version }}{{/with}}{{/with}}

Context

{
    "version": "2.0",
    "a": {
        "b": {
            "x": 1
        }
    }
}

Output

2.0

parent-pointer-three-levels-up

../../../key ascends three stack levels, reaching the root from inside three nested with blocks.

Template

{{#with a }}{{#with b }}{{#with c }}{{ ../../../version }}{{/with}}{{/with}}{{/with}}

Context

{
    "version": "3.0",
    "a": {
        "b": {
            "c": {}
        }
    }
}

Output

3.0

parent-pointer-intermediate-ancestor

../key from inside a doubly-nested with block resolves against the intermediate ancestor, not the root.

Template

{{#with a }}{{#with b }}{{ ../name }}{{/with}}{{/with}}

Context

{
    "a": {
        "name": "level-a",
        "b": {
            "name": "level-b"
        }
    }
}

Output

level-a

parent-pointer-missing-key-returns-null

A parent pointer to a non-existent key returns null, which renders as the literal 'null'.

Template

{{#with user }}{{ ../missing }}{{/with}}

Context

{
    "user": {
        "name": "Alice"
    }
}

Output

null

Source fixture: render/parent-pointer.json