feat: backport configurable delimiters, backslash handling & keepTrailingNewline to 2.8.x#1325
Merged
jasmith-hs merged 3 commits intoJul 20, 2026
Conversation
…delimiters Backport of #1305 to master-2.8.x. Adds StringTokenScannerSymbols + StringTokenScanner for arbitrary multi-character delimiter strings, and switches TagToken/ExpressionToken/NoteToken to symbol-length accessors instead of hardcoded {{ }} offsets. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Backport of #1306 to master-2.8.x. Adds LegacyOverrides.handleBackslashInQuotesOnly (default false, added to the ALL preset) so that, when enabled, backslash is only treated as an escape inside quoted string literals — matching Jinja2 — and is left for the expression parser outside quotes. Both TokenScanner and StringTokenScanner respect the flag. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Backport of #1311 to master-2.8.x. Adds JinjavaConfig.isKeepTrailingNewline() (delegating to LegacyOverrides.getDefaultKeepTrailingNewlineBehavior(), which defaults to true on the 2.8.x line to preserve historical behaviour) and strips a single trailing newline in Jinjava when disabled. Enabled (strips) in the ALL preset. Adapted for 2.8.x: JinjavaConfig is a hand-written builder here (not Immutables), so isKeepTrailingNewline delegates via a nullable builder field rather than @Value.Default; TrailingNewlineTest reflects the 2.8.x keep-by-default semantics. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jasmith-hs
marked this pull request as ready for review
July 20, 2026 20:59
rewaddell
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backports three already-merged
master(3.0.0) PRs to themaster-2.8.xmaintenance line for the 2.8.4 release:StringTokenScannerSymbols: configurable multi-character delimiters (fixes Allow configurable block/variable/comment starts and ends #195)keepTrailingNewlineoption to match Python Jinja2's default of stripping a single trailing newlineWhy
These fixes/features shipped on the 3.0 line, but consumers still pinned to the 2.8.x line need them without taking the larger 3.0 upgrade. This brings the 2.8.4 release to parity for these three behaviours.
Notes on the backport
A direct cherry-pick was not viable:
masterhas diverged frommaster-2.8.xindependently of these PRs (JinjavaConfig was converted to Immutables;LegacyOverridesdroppedwhitespaceRequiredWithinTokens, added aTHREE_POINT_0preset and an unrelatediteratorOnlyReverseFilter). This is therefore a selective backport:TokenScanner(retains 2.8.x'swhitespaceRequiredWithinTokens),LegacyOverrides,JinjavaConfig(plain hand-written builder here, soisKeepTrailingNewline()delegates via a nullable builder field rather than@Value.Default), andJinjava.Backwards compatibility
LegacyOverrides/ config builder; they are enabled only in theLegacyOverrides.ALLpreset.THREE_POINT_0preset exists on 2.8.x, so nothing changes for existing default users.Testing
StringTokenScannerSymbolsTest,BackslashHandlingTest,TrailingNewlineTest(the last reworked to assert 2.8.x's keep-newline-by-default semantics).mvn clean verify: 2157 tests, 0 failures.jinjavamodule succeeded.This PR description was authored by Claude Code.