Skip to content

Conformance Examples 0.1.0 — Render: this-identifier

this-renders-current-context

{{ this }} renders the entire current context as compact JSON (unescaped, as it is not a string primitive).

Template

{{ this }}

Context

{
    "name": "Alice"
}

Output

{"name":"Alice"}

this-unescaped-renders-current-context

{{{ this }}} renders the entire current context as compact JSON without HTML escaping.

Template

{{{ this }}}

Context

{
    "name": "Alice"
}

Output

{"name":"Alice"}

this-slash-this-resolves-this-property

{{ this/this }} resolves the 'this' property at the root of the current context via the JSON Pointer formed by stripping the leading 'this'.

Template

{{ this/this }}

Context

{
    "this": "value-of-this"
}

Output

value-of-this

this-dot-this-resolves-this-property

{{ this.this }} resolves the 'this' property at the root of the current context via dot notation after stripping the leading 'this.' prefix.

Template

{{ this.this }}

Context

{
    "this": "value-of-this"
}

Output

value-of-this

dot-alone-renders-current-context

{{ . }} is a synonym for {{ this }} and renders the entire current context (unescaped, as it is not a string primitive).

Template

{{ . }}

Context

{
    "name": "Alice"
}

Output

{"name":"Alice"}

dot-slash-name-resolves-property

{{ ./name }} strips the leading './' and dispatches '/name' as an RFC 6901 pointer.

Template

{{ ./name }}

Context

{
    "name": "Alice"
}

Output

Alice

this-dot-nested-uses-dot-notation

{{ this.user.city }} strips the leading 'this.' and resolves 'user.city' as dot notation.

Template

{{ this.user.city }}

Context

{
    "user": {
        "city": "Springfield"
    }
}

Output

Springfield

this-slash-nested-uses-rfc6901

{{ this/user/city }} strips the leading 'this' and dispatches '/user/city' as an RFC 6901 pointer.

Template

{{ this/user/city }}

Context

{
    "user": {
        "city": "Springfield"
    }
}

Output

Springfield

this-with-null-context-renders-null

When the context is null, {{ this }} renders the literal 'null' (matching the existing null-context convention).

Template

{{ this }}

Output

null

thisfoo-is-not-a-this-keyword

Identifiers that merely start with the letters 'this' but are not followed by '.' or '/' or end-of-identifier are unaffected; 'thisfoo' is dispatched as the dot-notation key 'thisfoo'.

Template

{{ thisfoo }}

Context

{
    "thisfoo": "ok"
}

Output

ok

Source fixture: render/this-identifier.json