Skip to content

Commit 7beb3f8

Browse files
committed
Merge branch 'master' of https://github.com/HubSpot/jinjava into keep-undefined
2 parents 392e092 + 602a730 commit 7beb3f8

File tree

9 files changed

+76
-6
lines changed

9 files changed

+76
-6
lines changed

.build-jdk17

Whitespace-only changes.

.github/workflows/ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
java: [ 17 ]
10+
java: [ 17, 21, 25 ]
1111
name: jdk-${{ matrix.java }}
1212
steps:
1313
- uses: actions/checkout@v3
@@ -16,9 +16,19 @@ jobs:
1616
- uses: actions/setup-java@v3
1717
with:
1818
distribution: "temurin"
19-
java-version: ${{ matrix.java }}
19+
# The JDK listed last will be the default and what Maven runs with
20+
# https://github.com/marketplace/actions/setup-java-jdk#install-multiple-jdks
21+
java-version: |
22+
${{ matrix.java }}
23+
25
2024
cache: "maven"
2125
- name: "Build"
22-
run: mvn --batch-mode -no-transfer-progress -V verify
26+
run: |
27+
mvn \
28+
--batch-mode \
29+
-no-transfer-progress \
30+
-V \
31+
-Dproject.build.jdk.version=${{ matrix.java }} \
32+
verify
2333
env:
2434
JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Jinjava Releases #
2+
### 2025-10-22 Version 2.8.2 ([Maven Central](https://search.maven.org/artifact/com.hubspot.jinjava/jinjava/2.8.2/jar)) ###
3+
* [Fix helper token escape handling and unescaping when unquoting strings](https://github.com/HubSpot/jinjava/pull/1263)
24
### 2025-09-16 Version 2.8.1 ([Maven Central](https://search.maven.org/artifact/com.hubspot.jinjava/jinjava/2.8.1/jar)) ###
35
* Disallow accessing properties on restricted classes while rendering
46
* [Make stack operations use AutoCloseable for safer usage with try-with-resources](https://github.com/HubSpot/jinjava/pull/1250)

pom.xml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
<parent>
66
<groupId>com.hubspot</groupId>
77
<artifactId>basepom</artifactId>
8-
<version>63.4</version>
8+
<version>65.1</version>
99
</parent>
1010

1111
<groupId>com.hubspot.jinjava</groupId>
1212
<artifactId>jinjava</artifactId>
13-
<version>2.8.2-SNAPSHOT</version>
13+
<version>2.8.3-SNAPSHOT</version>
1414

1515
<name>${project.groupId}:${project.artifactId}</name>
1616
<description>Jinja templating engine implemented in Java</description>
1717

1818
<properties>
1919
<project.build.targetJdk>17</project.build.targetJdk>
20-
<project.build.releaseJdk>17</project.build.releaseJdk>
2120

2221
<dep.plugin.jacoco.version>0.8.3</dep.plugin.jacoco.version>
2322
<dep.plugin.javadoc.version>3.0.1</dep.plugin.javadoc.version>
2423
<dep.hubspot-immutables.version>1.9</dep.hubspot-immutables.version>
2524
<dep.algebra.version>1.5</dep.algebra.version>
25+
<dep.mockito.version>5.20.0</dep.mockito.version>
2626

2727

2828
<basepom.test.add.opens>
@@ -181,6 +181,10 @@
181181
<groupId>ch.obermuhlner</groupId>
182182
<artifactId>big-math</artifactId>
183183
</dependency>
184+
<dependency>
185+
<groupId>com.google.errorprone</groupId>
186+
<artifactId>error_prone_annotations</artifactId>
187+
</dependency>
184188

185189
<dependency>
186190
<groupId>ch.qos.logback</groupId>
@@ -336,6 +340,18 @@
336340
<argLine>@{argLine} ${basepom.test.add.opens}</argLine>
337341
</configuration>
338342
</plugin>
343+
<plugin>
344+
<groupId>org.apache.maven.plugins</groupId>
345+
<artifactId>maven-compiler-plugin</artifactId>
346+
<configuration>
347+
<annotationProcessorPaths>
348+
<path>
349+
<groupId>org.immutables</groupId>
350+
<artifactId>value</artifactId>
351+
</path>
352+
</annotationProcessorPaths>
353+
</configuration>
354+
</plugin>
339355
</plugins>
340356
</build>
341357

src/main/java/com/hubspot/jinjava/lib/tag/BreakTag.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.hubspot.jinjava.doc.annotations.JinjavaDoc;
44
import com.hubspot.jinjava.doc.annotations.JinjavaTextMateSnippet;
5+
import com.hubspot.jinjava.interpret.DeferredValue;
56
import com.hubspot.jinjava.interpret.DeferredValueException;
67
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
78
import com.hubspot.jinjava.interpret.NotInLoopException;
@@ -37,6 +38,8 @@ public String interpret(TagNode tagNode, JinjavaInterpreter interpreter) {
3738
}
3839
ForLoop forLoop = (ForLoop) loop;
3940
forLoop.doBreak();
41+
} else if (loop instanceof DeferredValue) {
42+
throw new DeferredValueException("Deferred break");
4043
} else {
4144
throw new NotInLoopException(TAG_NAME);
4245
}

src/main/java/com/hubspot/jinjava/lib/tag/ContinueTag.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.hubspot.jinjava.doc.annotations.JinjavaDoc;
44
import com.hubspot.jinjava.doc.annotations.JinjavaTextMateSnippet;
5+
import com.hubspot.jinjava.interpret.DeferredValue;
56
import com.hubspot.jinjava.interpret.DeferredValueException;
67
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
78
import com.hubspot.jinjava.interpret.NotInLoopException;
@@ -35,6 +36,8 @@ public String interpret(TagNode tagNode, JinjavaInterpreter interpreter) {
3536
}
3637
ForLoop forLoop = (ForLoop) loop;
3738
forLoop.doContinue();
39+
} else if (loop instanceof DeferredValue) {
40+
throw new DeferredValueException("Deferred continue");
3841
} else {
3942
throw new NotInLoopException(TAG_NAME);
4043
}

src/test/java/com/hubspot/jinjava/EagerTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,16 @@ public void itHandlesDeferredBreakInForLoop() {
16551655
assertThat(interpreter.getContext().getDeferredNodes()).isNotEmpty();
16561656
}
16571657

1658+
@Test
1659+
public void itHandlesBreakInDeferredForLoop() {
1660+
String input = expectedTemplateInterpreter.getFixtureTemplate(
1661+
"handles-break-in-deferred-for-loop/test"
1662+
);
1663+
interpreter.render(input);
1664+
// We don't support this yet
1665+
assertThat(interpreter.getContext().getDeferredNodes()).isNotEmpty();
1666+
}
1667+
16581668
@Test
16591669
public void itHandlesDeferredContinueInForLoop() {
16601670
String input = expectedTemplateInterpreter.getFixtureTemplate(
@@ -1665,6 +1675,16 @@ public void itHandlesDeferredContinueInForLoop() {
16651675
assertThat(interpreter.getContext().getDeferredNodes()).isNotEmpty();
16661676
}
16671677

1678+
@Test
1679+
public void itHandlesContinueInDeferredForLoop() {
1680+
String input = expectedTemplateInterpreter.getFixtureTemplate(
1681+
"handles-continue-in-deferred-for-loop/test"
1682+
);
1683+
interpreter.render(input);
1684+
// We don't support this yet
1685+
assertThat(interpreter.getContext().getDeferredNodes()).isNotEmpty();
1686+
}
1687+
16681688
@Test
16691689
public void itReconstructsFromedMacro() {
16701690
expectedTemplateInterpreter.assertExpectedOutput("reconstructs-fromed-macro/test");
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Start loop
2+
{% for i in deferred %}
3+
{% if i %}
4+
{% break %}
5+
{% endif %}
6+
i is: {{ i }}
7+
{% endfor %}
8+
End loop
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Start loop
2+
{% for i in deferred %}
3+
{% if i %}
4+
{% continue %}
5+
{% endif %}
6+
i is: {{ i }}
7+
{% endfor %}
8+
End loop

0 commit comments

Comments
 (0)