Skip to content

feat: backport configurable delimiters, backslash handling & keepTrailingNewline to 2.8.x#1325

Merged
jasmith-hs merged 3 commits into
master-2.8.xfrom
jasmith_hubspot/backport-1305-1306-1311-2.8.x
Jul 20, 2026
Merged

feat: backport configurable delimiters, backslash handling & keepTrailingNewline to 2.8.x#1325
jasmith-hs merged 3 commits into
master-2.8.xfrom
jasmith_hubspot/backport-1305-1306-1311-2.8.x

Conversation

@jasmith-hs

Copy link
Copy Markdown
Contributor

Description

Backports three already-merged master (3.0.0) PRs to the master-2.8.x maintenance line for the 2.8.4 release:

Why

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: master has diverged from master-2.8.x independently of these PRs (JinjavaConfig was converted to Immutables; LegacyOverrides dropped whitespaceRequiredWithinTokens, added a THREE_POINT_0 preset and an unrelated iteratorOnlyReverseFilter). This is therefore a selective backport:

  • Files whose only divergence from 2.8.x was the PR change were taken verbatim from upstream (the two new scanner classes plus the token classes).
  • Structurally-diverged files were hand-ported: TokenScanner (retains 2.8.x's whitespaceRequiredWithinTokens), LegacyOverrides, JinjavaConfig (plain hand-written builder here, so isKeepTrailingNewline() delegates via a nullable builder field rather than @Value.Default), and Jinjava.

Backwards compatibility

  • All three new behaviours default to the legacy 2.8.x behaviour and are opt-in via LegacyOverrides / config builder; they are enabled only in the LegacyOverrides.ALL preset.
  • No THREE_POINT_0 preset exists on 2.8.x, so nothing changes for existing default users.

Testing

  • New tests added: StringTokenScannerSymbolsTest, BackslashHandlingTest, TrailingNewlineTest (the last reworked to assert 2.8.x's keep-newline-by-default semantics).
  • Local mvn clean verify: 2157 tests, 0 failures.
  • Remote Blazar build on the pushed branch: jinjava module succeeded.

This PR description was authored by Claude Code.

jasmith-hs and others added 3 commits July 20, 2026 14:26
…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 jasmith-hs self-assigned this Jul 20, 2026
@jasmith-hs
jasmith-hs marked this pull request as ready for review July 20, 2026 20:59
@jasmith-hs
jasmith-hs merged commit df3e3d8 into master-2.8.x Jul 20, 2026
7 checks passed
@jasmith-hs
jasmith-hs deleted the jasmith_hubspot/backport-1305-1306-1311-2.8.x branch July 20, 2026 22: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.

2 participants