Repository navigation
Make compatibility fixes opt-out: block-scoped inline partials by default, opt-outs named in exceptions - #692
Conversation
…inePartialScoping opt-out Brings in the block-scoped inline partial implementation from #688 (which added it as the opt-in Compatibility.BlockScopedInlinePartials) and inverts it: handlebars.js scoping is now the default, and the earlier behavior is restored with Compatibility.LegacyInlinePartialScoping = true. The "Referenced partial name '...' could not be resolved" exception now names the opt-out when it is not set. Refs #673, #690 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hen {{^}} caused it
With {{^}} treated as the inverse separator, {{#if x}}a{{^}}b{{^}}c{{/if}}
now fails with "'{{else}}' cannot follow another '{{else}}'". When the
offending separator was a bare {{^}}, the message now explains that and
names Compatibility.LegacyStandaloneCaretBehavior as the opt-out.
Refs #690
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Resolve merge conflicts |
…to true #688 merged and shipped in 2.4.4 with Compatibility.BlockScopedInlinePartials as an opt-in. Instead of replacing it with a new LegacyInlinePartialScoping flag (which would remove a released public property), keep the released property and flip its default to true. Setting it to false is the opt-out, and the unresolved-partial exception names that. Refs #690 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merge conflicts are resolved. I merged The conflicts came from #688, which merged and then shipped in 2.4.4 with
Code that set the flag to |
|



Closes #690
Summary
Per #690, for the next minor release every compatibility flag that gates a bug fix is now an opt-out: the fixed (handlebars.js) behavior is the default, and the flag restores the old behavior. Where the fixed behavior throws, the exception message names the opt-out.
LegacyStandaloneCaretBehavior(#672)BlockScopedInlinePartials(#673, #688)falsetrue. Set it tofalseto opt out. The missing-partial exception names the opt-out.RelaxedHelperNamingSupportLastInObjectIterationsWhy the existing flag is kept
An earlier revision of this PR replaced
BlockScopedInlinePartialswith a newLegacyInlinePartialScoping. Since then #688 merged, and 2.4.4 shippedBlockScopedInlinePartialsas public API. Removing it now would break code that sets it at compile time. So this PR keeps that property and only flips its default:BlockScopedInlinePartials = trueon 2.4.4 keeps compiling and gets the same behavior.falserestores the 2.4.x behavior.What changes for existing users
Output of the templates below with no flag set on 2.4.4, then on this branch with no flag set and with the opt-out:
BlockScopedInlinePartials = false{{#*inline "p"}}outer{{/inline}}{{#with .}}{{#*inline "p"}}inner{{/inline}}{{> p}}{{/with}} {{> p}}inner innerinner outerinner inner{{#with .}}{{#*inline "myPartial"}}success{{/inline}}{{/with}}{{> myPartial}}successsuccess{{> macros}}{{> button label="OK"}}, where partialmacrosdeclares{{#*inline "button"}}<button>OK</button><button>OK</button>The new exception text:
The sentence about the opt-out is added only while scoping is on. If a
MissingPartialTemplateHandleris configured, that handler runs instead, as before.{{^}}exception messageWhen
{{^}}is the inverse separator,{{#if x}}a{{^}}b{{^}}c{{/if}}(or{{#unless x}}a{{else}}b{{^}}c{{/unless}}) fails to compile, where it rendered before the{{^}}fix. The message now reads:This sentence is added only when the second separator really was a
{{^}}. A{{else}}after{{else}}keeps the old message. To support this,HelperExpressionhas a new internalIsStandaloneCaretmarker.InverseSeparatorConvertersets it andHelperArgumentAccumulatorcarries it forward. No other block type throws on a repeated{{^}}.Migration for users who hit the change
RegisterTemplate. Both work in every mode.handlebars.Configuration.Compatibility.BlockScopedInlinePartials = falseto get exactly the 2.4.x default behavior. The flag is read at compile time, so set it before callingCompile.Release
This is the intentional behavior change #690 asks for, and it goes in the next minor release (2.5.0). Every affected template can get the old behavior back with one flag. Suggested release-notes entries:
Compatibility.BlockScopedInlinePartialsnow defaults totrue. Inline partials declared inside a block or partial are scoped to that block, as in handlebars.js. Set it tofalseto restore the previous behavior. (Inline partials declared inside a block stay registered after the block ends #673, Invert opt-ins for breaking bug fixes in next minor version release #690){{else}}" error caused by a repeated{{^}}now namesCompatibility.LegacyStandaloneCaretBehavior. (Invert opt-ins for breaking bug fixes in next minor version release #690)Tests
InlinePartialTests:true.#each, last definition wins, custom decorator between inlines,{{#> layout}}partial blocks, repeated renders, and partials declared in an included partial.false.HandlebarsSpecCoverageTests: a repeated{{^}}in#ifand#unlessnames the opt-out and compiles under the legacy flag; a repeated{{else}}does not mention it.master, the full suite passes (2291/2291 on net10.0). The library builds for all target frameworks.🤖 Generated with Claude Code
Closes #690