For the provided string in my model, I want to print a "growing" list of substrings. For example, if the given string is Wine, the result should be:
W
Wi
Win
Wine
I've come up with the following construct:
<h1 th:with="len=${#strings.length(name)}" th:each="i : ${#numbers.sequence(1, ${len})}" th:text="${#strings.substring(name, 0, i)}"></h1>
but it doesn't work.
If I change ${#numbers.sequence(1, ${len})} to ${#numbers.sequence(1, 4)} it works. However, this way I'd need to manually change the code whenever my initial string's length changes.
I've tried with messages.msg() alternative, but no luck either.
Error:
An error happened during template parsing (template: "class path resource [templates/name-list.html]")
Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "#numbers.sequence(1, ${len})" (template: "name-list" - line 7, col 53)
What am I doing wrong?