Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is recommended file suffix for Thymeleaf templates?

Tags:

thymeleaf

I see that JSP pages have .jsp/.jspf/.jspx suffixes (from JavaServer Pages™ Specification Version2.2), Velocity templates uses .vm suffix, FreeMarker uses .ftl suffix.

What is recommended file suffix for Thymeleaf templates according to official body/docs/IDE expectation?

.html suffix can mislead with pure HTML 5 files. For that reason I think about putting all Thymleaf templates into thy/ hierarchy and pure HTML files keep inside html/ directory.

like image 664
gavenkoa Avatar asked Jul 02 '17 12:07

gavenkoa


People also ask

Where do I put Thymeleaf templates?

Thymeleaf template files are located in the custom src/main/resources/mytemplates directory. The default template directory is src/main/resources/templates . This is the Maven build file.

What is Thymeleaf template?

Thymeleaf is a modern server-side Java template engine for both web and standalone environments, capable of processing HTML, XML, JavaScript, CSS and even plain text. The main goal of Thymeleaf is to provide an elegant and highly-maintainable way of creating templates.

What is Thymeleaf extension?

Last modified: 13 June 2022. Required plugin: Thymeleaf (bundled) Thymeleaf is a server-side Java template engine for both web and standalone environments. Its main goal is to bring natural templates to your development workflow — HTML that can be correctly displayed in browsers and also work as static prototypes.


1 Answers

Thymeleaf uses natural templates. A HTML5 Thymeleaf template can (and should) be a valid HTML document. Therefore these templates do not need its own extension, opposite to for example Velocity and Freemarker.

To distinguish Thymeleaf templates from other HTML files you could put them in a directory called templates, this is what the official Spring integration tutorial uses.

like image 156
holmis83 Avatar answered Sep 28 '22 15:09

holmis83