xxxxxxxxxx
You can use local variables. Declare an HTML element with a th:with attribute. For example <div th:with="someVariable=${someValue}"
xxxxxxxxxx
<script th:inline="javascript"> // Enable Thymeleaf inlining
var email = [[${user.email}]]; // Behaves just like in HTML
</script>
xxxxxxxxxx
<div th:with="name=${user.name}">
<p>
Hey there! I'm <span th:text="${name}">Atta</span>!
</p>
</div>