Skip to content

Commit 4141a4d

Browse files
authored
Add org.thymeleaf.engine.IterationStatusVar (#526)
1 parent b995180 commit 4141a4d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

metadata/org.thymeleaf/thymeleaf/3.1.0.RC1/reflect-config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,5 +404,17 @@
404404
"condition": {
405405
"typeReachable": "org.thymeleaf.standard.expression.StandardExpressionParser"
406406
}
407+
},
408+
{
409+
"name": "org.thymeleaf.engine.IterationStatusVar",
410+
"allDeclaredConstructors": true,
411+
"allPublicConstructors": true,
412+
"allDeclaredMethods": true,
413+
"allPublicMethods": true,
414+
"allDeclaredClasses": true,
415+
"allPublicClasses": true,
416+
"condition": {
417+
"typeReachable": "org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator"
418+
}
407419
}
408420
]

tests/src/org.thymeleaf/thymeleaf/3.1.0.RC1/src/test/java/org/thymeleaf/ThymeleafTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,13 @@ void renderTemporalsExpression() {
185185
assertThat(output).startsWith("<p>15/06/1981</p>");
186186
}
187187

188-
188+
@Test
189+
void renderIteratorStatus() {
190+
TemplateEngine templateEngine = new TemplateEngine();
191+
Context context = new Context();
192+
context.setVariable("array", new String[] {"one", "two"});
193+
String template = "<ul><li th:each=\"v, iterStat:${array}\" th:class=\"${iterStat.odd}? 'odd'\" th:text=\"${v}\">value</li></ul>";
194+
String output = templateEngine.process(template, context);
195+
assertThat(output).startsWith("<ul><li class=\"odd\">one</li><li>two</li></ul>");
196+
}
189197
}

0 commit comments

Comments
 (0)