dt:tmpl |
Basic Thymeleaf HTML template |
Thymeleaf HTML template with data attributes |
dt:text |
data-th-text="${variable}" |
Sets the text content of an element (escapes HTML) |
dt:utext |
data-th-utext="${variable}" |
Sets unescaped text content (renders HTML as-is) |
dt:value |
data-th-value="${variable}" |
Specify the initial value for an input element |
dt:if |
data-th-if="${condition}" |
Renders the element only if the condition is true |
dt:unless |
data-th-unless="${condition}" |
Renders the element only if the condition is false |
dt:each |
data-th-each="item_name : ${list_name}" |
Iterates over a collection (like a loop) |
dt:object |
data-th-object="${variable}" |
Binds a form to a model attribute (e.g., a command object) |
dt:field |
data-th-field="*{object_variable_name}" |
Binds an input field to a property of the th:object |
dt:href |
data-th-href="@{url}" |
Dynamically sets the href attribute (URLs) |
dt:src |
data-th-src="${variable}" |
Specify the URI of an image, iframe, or other embedded resource |
dt:style |
data-th-style="${variable}" |
Specify inline CSS styles for an element |
dt:classappend |
data-th-classappend="${condition} ? 'css_class' : ''" |
Appends CSS classes conditionally |
dt:attr |
data-th-attr="data-attribute=${variable}" |
Set arbitrary attributes for an element |
dt:fragment |
data-th-fragment="${fragment_name}" |
Defines a reusable template fragment |
dt:replace |
data-th-replace="~{fragment_path :: fragment_name}" |
Replaces the current element with a fragment |
dt:include |
data-th-include="~{fragment_path :: fragment_name}" |
Includes a fragment (deprecated in Thymeleaf 3) |
dt:block |
data-th-block="${variable_name}" |
A non-rendered container for logic (e.g., loops/conditionals) |
dt:switch |
data-th-switch="${variable_name}" |
Switch-case logic for conditional rendering |
dt:case |
data-th-case="value" |
Defines a case in a switch statement |
dt:with |
data-th-with="variable_name" |
Defines local variables for use within the element |
dt:insert |
data-th-insert="~{fragment_path :: fragment_name}" |
Inserts a fragment into the current element |
dt:remove |
data-th-remove="all" |
Remove element from output |