Skip to content

Commit

Permalink
Add org.thymeleaf.engine.IterationStatusVar (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego authored Oct 4, 2024
1 parent b995180 commit 4141a4d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions metadata/org.thymeleaf/thymeleaf/3.1.0.RC1/reflect-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,5 +404,17 @@
"condition": {
"typeReachable": "org.thymeleaf.standard.expression.StandardExpressionParser"
}
},
{
"name": "org.thymeleaf.engine.IterationStatusVar",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredClasses": true,
"allPublicClasses": true,
"condition": {
"typeReachable": "org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,13 @@ void renderTemporalsExpression() {
assertThat(output).startsWith("<p>15/06/1981</p>");
}


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

0 comments on commit 4141a4d

Please sign in to comment.