Skip to content

fix: preserve double backslash in static template text (issue #349)#640

Merged
rexm merged 2 commits into
masterfrom
fix/issue-349
Jun 20, 2026
Merged

fix: preserve double backslash in static template text (issue #349)#640
rexm merged 2 commits into
masterfrom
fix/issue-349

Conversation

@rexm

@rexm rexm commented Jun 20, 2026

Copy link
Copy Markdown
Member

Fixes #349

Summary

  • \\ in static template text not followed by {{ now passes through verbatim instead of being collapsed to a single \
  • \\{{ still emits a single \ before the expression (spec-compliant escape behavior preserved)

Root cause

In Tokenizer.cs, the \\ branch unconditionally consumed both backslashes and emitted only one. The fix peeks at the character after the second \: if it's {, the original behavior is kept; otherwise both backslashes are emitted verbatim.

Test plan

  • DoubleBackslashNotBeforeMustachePassesThroughVerbatim — core bug fix
  • DoubleBackslashNotBeforeMustacheInJsonLikeTemplate — JSON scenario from the issue
  • DoubleBackslashBeforeMustacheStillProducesSingleBackslash — spec escape behavior preserved
  • SingleBackslashNotBeforeMustachePassesThroughVerbatim — single backslash unchanged
  • Full suite: 1750 tests pass

🤖 Generated with Claude Code

\\ not followed by {{ now passes through verbatim. \\{{ still emits a
single \ before the expression (spec-compliant escape behavior preserved).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Issue349 test methods were spliced inside Issue458_BlockHelperTemplateCompilationAndRender,
causing CS0106 compiler errors on the nested public modifiers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@rexm rexm enabled auto-merge June 20, 2026 20:37
@rexm rexm merged commit 6c16f30 into master Jun 20, 2026
7 checks passed
@rexm rexm deleted the fix/issue-349 branch June 20, 2026 20:44
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.

There seems to be an issue during compile with at least one escape sequence

1 participant