Search code examples
twitter-bootstrapspring-bootthymeleaf

How to show bootstrap tooltip title from variable in Thymeleaf?


Is there any way to show bootstrap tooltip title from variables in thymeleaf? Bootstrap tooltip static title in thymeleaf is:

<td th:text="${user.firstName}" data-toggle="tooltip" data-placement="top" title="Lastname: Lopez" />

I am looking something similar to

<td th:text="${user.firstName}" data-toggle="tooltip" data-placement="top" th:title="'Lastname: ' + ${user.lastName}" />

Solution

  • th:title is the correct way. See https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#setting-value-to-specific-attributes for a list of all possible attributes.