HOME

TheInfoList



OR:

Thymeleaf is a
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
/
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
/
HTML5 HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major HTML version that is a World Wide Web Consortium (W3C) recommendation. The current specification is known as the HTML ...
template engine that can work both in web (
servlet A Jakarta Servlet (formerly Java Servlet) is a Java software component that extends the capabilities of a server. Although servlets can respond to many types of requests, they most commonly implement web containers for hosting web application ...
-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 The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the ...
integration. In web applications Thymeleaf aims to be a complete substitute for
JavaServer Pages Jakarta Server Pages (JSP; formerly JavaServer Pages) is a collection of technologies that helps software developers create dynamically generated web pages based on HTML, XML, SOAP, or other document types. Released in 1999 by Sun Microsystems, J ...
(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 Open-source software (OSS) is computer software that is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute the software and its source code to anyone and for any purpose. Op ...
, licensed under the Apache License 2.0.


Features

From the project's website: Thymeleaf Features * Java template engine for
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
,
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
and
HTML5 HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major HTML version that is a World Wide Web Consortium (W3C) recommendation. The current specification is known as the HTML ...
. * Works both in web and non-web (offline) environments. No hard dependency on the
Servlet A Jakarta Servlet (formerly Java Servlet) is a Java software component that extends the capabilities of a server. Although servlets can respond to many types of requests, they most commonly implement web containers for hosting web application ...
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 Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
: validating against a DTD or not. **
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
1.0 and 1.1: validating against standard DTDs or not. **
HTML5 HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major HTML version that is a World Wide Web Consortium (W3C) recommendation. The current specification is known as the HTML ...
: both XML-formed code and legacy-based HTML5. Legacy non-XML code will be automatically cleaned and converted to
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
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

The following example produces an HTML5 table with rows for each item of a ''List'' variable called ''allProducts''.
Name Price
Oranges 0.99
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

*
Template engine (web) A web template system in web publishing lets web designers and developers work with ''web templates'' to automatically generate custom web pages, such as the results from a search. This reuses static web page elements while defining dynamic el ...
*
JavaServer Pages Jakarta Server Pages (JSP; formerly JavaServer Pages) is a collection of technologies that helps software developers create dynamically generated web pages based on HTML, XML, SOAP, or other document types. Released in 1999 by Sun Microsystems, J ...
*
Spring Framework The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the ...
*
FreeMarker Apache FreeMarker is a free Java-based template engine, originally focusing on dynamic web page generation with MVC software architecture. However, it is a general purpose template engine, with no dependency on servlets or HTTP or HTML, and i ...
*
Apache Velocity Apache Velocity first released in April 2001, is a Java-based template engine that provides a template language to reference objects defined in Java code. It aims to ensure clean separation between the presentation tier and business tiers in a W ...
*
Template Attribute Language The Template Attribute Language (TAL) is a templating language used to generate dynamic HTML and XML pages. Its main goal is to simplify the collaboration between programmers and designers. This is achieved by embedding TAL statements inside valid ...


References

{{Reflist


External links


Thymeleaf
Java enterprise platform Template engines Java (programming language) libraries Free software programmed in Java (programming language)