I have a text to render in three different possible colors using thymeleaf.
So the code I\'ve made so far to test the value is:
th:i
In my opinion, a better and more maintainable solution could be to write the evaluation code in a proper class.
class Evaluator{
private int value;
....
public boolean isBounded() {
return value < 49 && value > 29;
}
then in thymeleaf, call the function:
<p th:if="${evaluator.isBounded()} ...
Some benefits:
I hope this helps.
This is what worked for me:
th:if="${evaluation lt 49 and evaluation gt 29}"
I did this to have multiple conditions in th:if
in thymeleaf
<div
th:if="${object.getStatus()} == 'active' and ${object.getActiveDate()}"
th:text="${#dates.format(object.getActiveDate(), 'yyyy-MM-dd')}"
</div>
I added the and operator between conditions. You can also add or if needed.
I got the answer from the thymeleaf forum. The way to do it is :
th:if="${evaluation < 49 and evaluation > 29}"
Problem solved !