Skip to content

Add template inheritance ({{<parent}} and {{$block}} tags) - #851

Open
fig-ambassador wants to merge 3 commits into
janl:masterfrom
fig-ambassador:template-inheritance
Open

fig-ambassador wants to merge 3 commits into
janl:masterfrom
fig-ambassador:template-inheritance

Conversation

@fig-ambassador

Copy link
Copy Markdown

Implements the optional template inheritance module that entered the Mustache spec in v1.2.0. Fixes #825.

A parent tag renders the named template from the existing partials argument, with its $block sections replaced by the ones supplied between the parent's opening and closing tags. Blocks fall back to their default content, and a parent given no blocks behaves exactly like a partial. The public API is unchanged.

Three commits:

  1. The implementation and its tests.
  2. The mustache spec submodule updated to v1.4.3 — the old pin was from 2012 and predated nine years of spec work. All 27 inheritance tests run and pass. Seventeen spec tests covering behavior mustache.js does not have yet (refs Resolve dotted names against the first resolution, not a parent context #846 and Dynamic names #828) go into the harness's existing skipTests map; run them with NOSKIP=true.
  3. README documentation for blocks and parents.

One behavior changes: a lone {{$foo}} or {{<foo}} with no closing tag used to parse as interpolation of a key literally named "$foo" or "<foo". Both characters now start a tag, so it is a parse error, as in other implementations of this module.

Full suite: 361 passing / 30 pending / 0 failing, from Node 0.10 (the built file is genuine ES5) through current.

This was built by Fig, a fleet of AI agents. Abel McElroy (@abelmcelroy) directs it and is accountable for this work.

Implements the optional template inheritance module that entered the
Mustache spec in v1.2.0, one month after mustache.js 4.2.0 shipped.
A parent tag renders the named template from the existing partials
argument, with its $block sections replaced by the ones supplied
between the parent's opening and closing tags. Blocks fall back to
their default content, and a parent given no blocks behaves exactly
like a partial. The public API is unchanged.

One behavior changes: a lone {{$foo}} or {{<foo}} with no closing
tag used to parse as interpolation of a key literally named "$foo"
or "<foo". Both characters now start a tag, so it is a parse error,
as in other implementations of this module.

Fixes janl#825
The pin was from 2012 and predated nine years of spec work,
including the inheritance module, whose 27 tests now run and pass.
The old pin also hid a gap: its interpolation.json lagged behind its
own interpolation.yml, so the "Dotted Names - Context Precedence"
test has never actually run here.

Seventeen tests cover behavior mustache.js does not have yet: that
dotted-names test (refs janl#846) and sixteen from the optional
dynamic-names module (refs janl#828). They go into the harness's
existing skipTests map; run them with NOSKIP=true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: {{<parent}} blocks

1 participant