I am using thymeleaf
in front end and I know variable
concept in thymeleaf
<span th:with="var=${someValue}" th:text="${var}"></span>
if I use th:text
the value in the variable will be printed and I can use that variable in the same element, Is there any way to use the var
in other element like
<span th:with="var=${someValue}"></span>
<span th:text="${var}"></span>
I need to provide global scope
to that variable is it possible in thymeleaf ?
Define var
in the opening body
tag
<body th:with="var=${var_value}">
Only nested item can see variable. Div tag is only an example. You can use tags you wants
<div th:with="var=${var_value}">
inside div tag var is visible.
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With