Skip to content

test: cover chaining built-in {{else with}} under {{#if}} - #689

Merged
stencil-harness[bot] merged 2 commits into
masterfrom
robot/issue-683
Nov 21, 2026
Merged

stencil-harness[bot] merged 2 commits into
masterfrom
robot/issue-683

Conversation

@stencil-harness

Copy link
Copy Markdown
Contributor

Refs #683. Follow-up to #687. This PR changes tests only; there are no library changes.

Adds IfChainsToBuiltInWithHelper to source/Handlebars.Test/ConditionalElseChainTests.cs. It checks that {{#if a}}A{{else with b}}{{c}}{{/if}} chains to the built-in with helper, so {{c}} resolves against b. The case comes from #684 (by @EnesKartal). It was the one scenario in #684's tests that #687 didn't already cover.

#684 vs. merged #687 (actual runs of both)

Template Data #687 (merged) #684
{{#if a}}A{{else ifEq b "x"}}B{{else}}C{{/if}} a=false, b="x" B B
{{#if a}}A{{else ifEq b "y"}}B{{/if}} a=false, b="x" `` ``
{{#if a}}A{{else unless b}}B{{else}}C{{/if}} a=false, b=false B B
{{#if a}}A{{else if b includeZero=true}}B{{else}}C{{/if}} a=false, b=0 B B
{{#if a}}A{{else if b c}}B{{/if}} HandlebarsCompilerException HandlebarsCompilerException
{{#if a}}A{{else}}B{{else}}C{{/if}} HandlebarsCompilerException ArgumentNullException
{{#if a}}A{{else if}}B{{/if}} a=false B (unchanged from before) HandlebarsCompilerException
{{#if a}}A{{else isAdmin}}B{{/if}} a=false, isAdmin=false B (unchanged from before) ``
{{#if a}}A{{else items}}[{{this}}]{{/if}} a=false, items=[1,2] [{ a = False, … }] (unchanged) [1][2]
{{#if a}}A{{else "x" b}}B{{/if}} a=false, b=false `` (unchanged) B

Both PRs fix the reported bug. #687 additionally turns the double-{{else}} case into a HandlebarsCompilerException. The two diverge only where a bare {{else name}} has no further arguments. #687 keeps the existing behaviour there, while #684 switches to handlebars.js semantics. That switch changes output for templates that compile today, so it has been raised separately on #683 as an owner decision rather than shipped here.

Full suite: dotnet test source/Handlebars.Test/Handlebars.Test.csproj: 2271 passed, 0 failed.

🤖 Generated with Claude Code

Closes #683

@sonarqubecloud

Copy link
Copy Markdown

@stencil-harness
stencil-harness Bot merged commit 39e91b2 into master Nov 21, 2026
7 checks passed
@stencil-harness
stencil-harness Bot deleted the robot/issue-683 branch November 21, 2026 20:30
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.

{{else customHelper args}} inside {{#if}} / {{#unless}} throws ArgumentNullException (Parameter 'test') at compile time

0 participants