fbpx
Wikipedia

Thymeleaf

Thymeleaf is a Java XML/XHTML/HTML5 template engine that can work both in web (servlet-based) and non-web environments. It is better suited for serving XHTML/HTML5 at the view layer of MVC-based web applications, but it can process any XML file even in offline environments. It provides full Spring Framework integration.

Thymeleaf
Developer(s)Daniel Fernández
Stable release
3.1.1[1] / December 6, 2022; 17 months ago (2022-12-06)
Written inJava
Operating systemCross-platform
Standard(s)XML, XHTML, HTML5
TypeTemplate Engine
LicenseApache License 2.0
Websitewww.thymeleaf.org

In web applications Thymeleaf aims to be a complete substitute for JavaServer Pages (JSP), and implements the concept of Natural Templates: template files that can be directly opened in browsers and that still display correctly as web pages.

Thymeleaf is open-source software, licensed under the Apache License 2.0.

Features edit

From the project's website:[2]

  • Java template engine for XML, XHTML and HTML5.
  • Works both in web and non-web (offline) environments. No hard dependency on the Servlet API.
  • Based on modular feature sets called dialects.
    • Dialect features (e.g.: evaluation, iteration, etc.) are applied by linking them to template's tags and/or attributes.
    • Two dialects available out-of-the-box: Standard and SpringStandard (for Spring MVC apps, same syntax as Standard).
    • Developers can extend and create custom dialects.
  • Several template modes:
    • XML: validating against a DTD or not.
    • XHTML 1.0 and 1.1: validating against standard DTDs or not.
    • HTML5: both XML-formed code and legacy-based HTML5. Legacy non-XML code will be automatically cleaned and converted to XML form.
  • Full (and extensible) internationalization support.
  • Configurable, high performance parsed template cache that reduces input/output to the minimum.
  • Automatic DOCTYPE translations –from template DTD to result DTD– for (optional) validation of both template and result code.
  • Extremely extensible: can be used as a template engine framework if needed.
  • Complete documentation including several example applications.

Thymeleaf example edit

The following example produces an HTML5 table with rows for each item of a List<Product> variable called allProducts.

<table> <thead> <tr> <th th:text="#{msgs.headers.name}">Name</th> <th th:text="#{msgs.headers.price}">Price</th> </tr> </thead> <tbody> <tr th:each="prod : ${allProducts}"> <td th:text="${prod.name}">Oranges</td> <td th:text="${#numbers.formatDecimal(prod.price,1,2)}">0.99</td> </tr> </tbody> </table> 

This piece of code includes:

  • Internationalization expressions: #{ ... } rh
  • Variable/model-attribute evaluation expressions: ${ ... }
  • Utility functions: #numbers.formatDecimal( ... )

Also, this fragment of (X)HTML code can be perfectly displayed by a browser as a prototype, without being processed at all: it is a natural template.

See also edit

References edit

  1. ^ "Thymeleaf 3.1: What's new and how to migrate - Thymeleaf".
  2. ^ . Archived from the original on 2011-10-08. Retrieved 2011-10-16. Thymeleaf Features

External links edit

  • Thymeleaf

thymeleaf, java, xhtml, html5, template, engine, that, work, both, servlet, based, environments, better, suited, serving, xhtml, html5, view, layer, based, applications, process, file, even, offline, environments, provides, full, spring, framework, integration. Thymeleaf is a Java XML XHTML HTML5 template engine that can work both in web servlet based and non web environments It is better suited for serving XHTML HTML5 at the view layer of MVC based web applications but it can process any XML file even in offline environments It provides full Spring Framework integration ThymeleafDeveloper s Daniel FernandezStable release3 1 1 1 December 6 2022 17 months ago 2022 12 06 Written inJavaOperating systemCross platformStandard s XML XHTML HTML5TypeTemplate EngineLicenseApache License 2 0Websitewww wbr thymeleaf wbr org In web applications Thymeleaf aims to be a complete substitute for JavaServer Pages JSP and implements the concept of Natural Templates template files that can be directly opened in browsers and that still display correctly as web pages Thymeleaf is open source software licensed under the Apache License 2 0 Contents 1 Features 2 Thymeleaf example 3 See also 4 References 5 External linksFeatures editFrom the project s website 2 Java template engine for XML XHTML and HTML5 Works both in web and non web offline environments No hard dependency on the Servlet API Based on modular feature sets called dialects Dialect features e g evaluation iteration etc are applied by linking them to template s tags and or attributes Two dialects available out of the box Standard and SpringStandard for Spring MVC apps same syntax as Standard Developers can extend and create custom dialects Several template modes XML validating against a DTD or not XHTML 1 0 and 1 1 validating against standard DTDs or not HTML5 both XML formed code and legacy based HTML5 Legacy non XML code will be automatically cleaned and converted to XML form Full and extensible internationalization support Configurable high performance parsed template cache that reduces input output to the minimum Automatic DOCTYPE translations from template DTD to result DTD for optional validation of both template and result code Extremely extensible can be used as a template engine framework if needed Complete documentation including several example applications Thymeleaf example editThe following example produces an HTML5 table with rows for each item of a List lt Product gt variable called allProducts lt table gt lt thead gt lt tr gt lt th th text msgs headers name gt Name lt th gt lt th th text msgs headers price gt Price lt th gt lt tr gt lt thead gt lt tbody gt lt tr th each prod allProducts gt lt td th text prod name gt Oranges lt td gt lt td th text numbers formatDecimal prod price 1 2 gt 0 99 lt td gt lt tr gt lt tbody gt lt table gt This piece of code includes Internationalization expressions rh Variable model attribute evaluation expressions Utility functions numbers formatDecimal Also this fragment of X HTML code can be perfectly displayed by a browser as a prototype without being processed at all it is a natural template See also editTemplate engine web JavaServer Pages Spring Framework FreeMarker Apache Velocity Template Attribute LanguageReferences edit Thymeleaf 3 1 What s new and how to migrate Thymeleaf Features Thymeleaf Java XML XHTML HTML5 template engine Archived from the original on 2011 10 08 Retrieved 2011 10 16 Thymeleaf FeaturesExternal links editThymeleaf Retrieved from https en wikipedia org w index php title Thymeleaf amp oldid 1163701126, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.