I have a tasks and comments in every task. I use accordion to expand comment section, but problem is when i open One comment section opens all comments.
So in JAVA EE I solved this like that:
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse<%task.getId>" data-bs-target="#collapse" aria-expanded="false" aria-controls="collapse<%task.getId>">
You can see: <%task.getId> code inside of text to open each tasks comment separately by its id.
But how to write this in Spring Boot Thymeleaf? I tried:
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse__${task.getId}__" data-bs-target="#collapse" aria-expanded="false" aria-controls="collapse__${task.getId}__">
but ${} code remains green. So how to write Thymeleaf code inside of text without “th:??” ?
I tried __${code}__, but it doesnt work.
Using Kotlin (Spring Boot)
Thymeleaf only processes attributes prefixed with th:
. If you don’t have th:
it won’t get processed.
You can accomplish something similar to what you want with literal substitutions.
<button ... th:aria-controls="|collapse${task.getId}|">
2