Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Thymeleaf Snippets LiteNew to Visual Studio Code? Get it now.
Thymeleaf Snippets Lite

Thymeleaf Snippets Lite

duong-ca

|
1 install
| (0) | Free
Lightweight and useful VS Code snippets for Thymeleaf templates in Spring Boot applications.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Thymeleaf Snippets Lite

Lightweight and useful Thymeleaf snippets for Spring Boot applications in Visual Studio Code.


Features

Template Boilerplates

Prefix Snippet Description
thtemplate Basic Thymeleaf template Creates a complete HTML template with Thymeleaf namespace
thtemplate-sec Template with Spring Security Thymeleaf template including Spring Security namespace
thxml xmlns:th=\"http://www.thymeleaf.org\" Adds Thymeleaf XML namespace

Core Thymeleaf Attributes

Prefix Snippet Description
thtext th:text="${...}" Sets the text content of an element (escapes HTML)
thutext th:utext="${...}" Sets unescaped text content (renders HTML as-is)
thvalue th:value="${...}" Specify the initial value for an input element
thif th:if="${condition}" Renders the element only if the condition is true
thunless th:unless="${condition}" Renders the element only if the condition is false
theach th:each="item : ${list}" Iterates over a collection
thobject th:object="${model}" Binds a form to a model attribute
thfield th:field="*{property}" Binds an input field to a property
thhref th:href="@{url}" Dynamically sets the href attribute
thsrc th:src="${url}" Specify the URI of an image or resource
thattr th:attr="data-xxx=${...}" Set arbitrary attributes for an element
thremove th:remove="all" Remove element from output

Layout & Fragments

Prefix Snippet Description
thfragment th:fragment="name" Defines a reusable template fragment
threplace th:replace="~{path :: fragment}" Replaces the current element with a fragment
thinsert th:insert="~{path :: fragment}" Inserts a fragment into the current element
thblock th:block Non-rendered container for logic
thwith th:with="var=${expression}" Defines local variables

Conditional & Control

Prefix Snippet Description
thswitch th:switch="${variable}" Switch-case logic
thcase th:case="value" Defines a case in switch

Spring Security Snippets

Prefix Snippet Description
secauth sec:authorize="..." Authorization control
secrole sec:authorize="hasRole('ROLE_...')" Role-based authorization
secauthority sec:authorize="hasAuthority('...')" Authority check
secauthenticated sec:authorize="isAuthenticated()" Check if user is logged in
secauthen sec:authentication="..." Access Authentication object

Utility Snippets

Prefix Snippet Description
util.str.upper ${#strings.toUpperCase(str)} Convert string to uppercase
util.str.lower ${#strings.toLowerCase(str)} Convert string to lowercase
util.list.size ${#lists.size(list)} Get list size
util.list.empty ${#lists.isEmpty(list)} Check if list is empty
util.date.format ${#dates.format(date, 'dd/MM/yyyy')} Format date
util.num.format ${#numbers.formatDecimal(...)} Format number

Release Notes

0.1.0

  • Initial release

Hope you enjoy❤️

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft