Skip to content

Conformance Examples 0.1.0 — Partials: inline-partials

inline-partial-defines-and-is-used-in-the-same-block

An {{#inline name }} block defines a partial body directly usable by a {{> name }} reference in the same block, with no loader entry for that name.

Template

{{#inline greeting }}Hi{{/inline}}{{> greeting }}

Partials

Output

Hi

inline-partial-is-visible-before-its-own-definition

Because the whole block is scanned for inline definitions before any segment renders, a {{> name }} reference textually before its {{#inline name }} definition still resolves (hoisting), matching Handlebars' decorator pre-pass.

Template

{{> greeting }}{{#inline greeting }}Hi{{/inline}}

Partials

Output

Hi

inline-partial-renders-with-no-loader-registered

An inline partial resolves and renders even when no onLoadPartial loader is registered at all (the fixture's partials map is omitted): the hard NoPartialLoader failure only fires when a static key matches neither an inline definition nor a loader.

Template

{{#inline greeting }}Hi{{/inline}}{{> greeting }}

Output

Hi

inline-partial-shadows-a-loader-provided-partial-of-the-same-name

When an in-scope inline definition and a loader-resolvable key share a name, the inline definition wins; the loader is never consulted.

Template

{{#inline label }}INLINE{{/inline}}{{> label }}

Partials

label:

LOADED

Output

INLINE

inline-partial-is-visible-to-a-loaded-partial-invoked-from-the-same-block

Block scoping propagates into an invoked loaded partial: the shared RenderContext registry is not reset at partial boundaries, so a {{> label }} reference inside the loaded 'outer' partial resolves the inline 'label' defined in the block that invoked 'outer'.

Template

{{#inline label }}L{{/inline}}{{> outer }}

Partials

outer:

{{> label }}

Output

L

inline-partial-defined-inside-a-block-is-out-of-scope-after-that-block

An inline definition inside a {{#with}} block is visible for the duration of that block, but out of scope once rendering leaves it; a subsequent {{> label }} reference at the outer level falls through to the loader instead.

Template

{{#with person }}{{#inline label }}IN{{/inline}}{{> label }}{{/with}}{{> label }}

Context

{
    "person": {}
}

Partials

label:

OUT

Output

INOUT

dynamic-key-resolves-against-the-inline-scope

A dynamic {{> (expr) }} key is resolved against the inline scope exactly like a static key: the loader lookup that would otherwise run for the resolved key string is skipped once an inline definition matches.

Template

{{#inline greeting }}Hi{{/inline}}{{> (which) }}

Context

{
    "which": "greeting"
}

Partials

Output

Hi

Source fixture: partials/inline-partials.json