Skip to content

Conformance Examples 0.1.0 — Partials: partial-blocks

partial-block-renders-fallback-when-key-resolves-to-nothing

A static {{#> key }} … {{/>}} partial block whose key matches no inline definition and no loader entry renders its fallback body.

Template

{{#> myPartial }}Failover{{/>}}

Partials

Output

Failover

partial-block-hit-renders-the-partial-and-discards-the-fallback

When the key resolves against the loader, the resolved partial renders and the fallback body is discarded entirely.

Template

{{#> myPartial }}Failover{{/>}}

Partials

myPartial:

LOADED

Output

LOADED

partial-block-renders-fallback-with-no-loader-registered-at-all

Unlike a bare {{> key }} tag, which hard-fails with KB-4002 when no onLoadPartial loader is registered, a partial block with no loader at all (the fixture's partials map is omitted) renders its fallback instead.

Template

{{#> myPartial }}Failover{{/>}}

Output

Failover

partial-block-dynamic-key-hit-renders-the-resolved-partial

A dynamic {{#> (expr) }} key that resolves against the loader renders the resolved partial, discarding the fallback, exactly like the static-key hit case.

Template

{{#> (which) }}Failover{{/>}}

Context

{
    "which": "myPartial"
}

Partials

myPartial:

LOADED

Output

LOADED

partial-block-dynamic-key-miss-renders-fallback-with-no-soft-fail-reported

A dynamic key that resolves to nothing renders the fallback silently: unlike a bare {{> (expr) }} miss, which reports an UnresolvedReference (KB-5005) soft failure, a partial block's fallback is itself the miss handling, so no soft-fail event is emitted at all.

Template

{{#> (which) }}Failover{{/>}}

Context

{
    "which": "missing"
}

Partials

Output

Failover

partial-block-in-scope-inline-definition-shadows-the-loader

An in-scope {{#inline name }} definition wins over a loader entry of the same name, exactly as it does for a bare {{> name }} reference; the fallback is discarded because the inline definition counts as a hit.

Template

{{#inline myPartial }}INLINE{{/inline}}{{#> myPartial }}Failover{{/>}}

Partials

myPartial:

LOADED

Output

INLINE

partial-block-context-argument-applies-only-to-the-resolved-partial

The trailing context argument on {{#> key ctx }} pushes ctx as the resolved partial's scope on a hit, exactly like {{> key ctx }}; it has no bearing on the fallback, which is never rendered in this case.

Template

{{#> myPartial person }}Failover{{/>}}

Context

{
    "person": {
        "name": "Alice"
    }
}

Partials

myPartial:

{{ name }}

Output

Alice

partial-block-fallback-renders-against-the-current-context-not-the-context-argument

On a miss, the fallback is inline template content, not a partial invocation: it renders against the current context, never against the block's context argument, since the context argument only ever applies to the resolved partial on a hit.

Template

{{#> myPartial person }}{{ name }}{{/>}}

Context

{
    "name": "Alice",
    "person": {
        "name": "Bob"
    }
}

Output

Alice

Source fixture: partials/partial-blocks.json