Core Features
- Java template engine for XML, XHTML and HTML5. Extensible to other template formats.
- 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 out-of-the-box (extensible):
- 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.
Standard and SpringStandard Dialects
- XML, XHTML 1.0, XHTML 1.1 and HTML5 support.
- Complete substitute for view-layer web technologies such as JSP.
- Easy-to-use, elegant syntax based on attributes only (these dialects include no tags).
- Great for web templates: <input type="text" th:field="*{name}" /> instead of <mylib:text field="name" />
- Natural templating for easy prototyping: display your templates statically in a browser (without running your app server).
- Expression evaluation: OGNL (Standard) and Spring Expression Language (SpringStandard).
- Complete integration with Spring MVC (SpringStandard): form binding, property editors, internationalization, etc.
- Spring WebFlow support (including AJAX events).
- Fully-featured template logic: iteration, conditional evaluation, context variable declaration, etc.
- Several options for layout (Composite View pattern):
- A builtin mechanism (Thymeleaf's native fragment inclusion).
- Specific Apache Tiles integration (through extras package).
- Can be used along with SiteMesh.
- Internationalization support: easy inclusion of externalized messages into templates.
- URL rewriting capabilities for adding context and session information to URLs.
- JavaScript and Dart inlining: intelligent evaluation of expressions inside javascript/dart code.
- Template validation support for XML, XHTML 1.0 and XHTML 1.1.
Extensibility
- Dialects:
- Out-of-the-box: Standard and SpringStandard dialects.
- New custom dialects can be created, and existing ones can be extended.
- Several dialects can be applied at the same time.
- Template resolution:
- Out-of-the-box: templates can be read as classloader or ServletContext resources, as well as files (from the filesystem) and by calling URLs.
- Custom template resolvers can be developed.
- Message resolution (for internationalization):
- Out-of-the-box:
- Standard dialect: Resolution of messages from .properties files for each template.
- SpringStandard dialect: Resolution of messages from Spring MessageSource objects.
- Custom message resolvers can be developed.
- Out-of-the-box:
- Template modes:
- Out-of-the-box: XML, VALIDXML, XHTML, VALIDXHTML, HTML5 and LEGACYHTML5.
- Can be extended to process anything that can be modelled as a DOM tree, as long as both a parser and a results writer are provided.
- Cache management:
- Out-of-the-box: comprehensive set of robust caches for templates, code fragments, messages and expressions.
- Can be extended to modify (or disable) standard cache strategies, and also create new ones for specific purposes.
- Advantages obtained through extension:
- Addition of required specific features to existing dialects.
- Creation of view-layer reusable components (à la JSP taglibs).
- Creation of custom templating systems for user-customizable applications.
Testing
Thymeleaf has its own specialized testing library, compatible with most general testing frameworks like JUnit. This library allows you to test your application's view layer, as well as any thymeleaf extensions you develop.
Learn more at the testing library page in GitHub.
Main Integrations
The Thymeleaf team and community have created a series of integrations for the following technologies:
- Apache Tiles 2.x: https://github.com/thymeleaf/thymeleaf-extras-tiles2
- Spring Security 3.x: https://github.com/thymeleaf/thymeleaf-extras-springsecurity3
- Eclipse IDE: https://github.com/thymeleaf/thymeleaf-extras-eclipse-plugin
- Play Framework 1.2: http://www.playframework.org/modules/thymeleaf
See more at the ecosystem page.
Other Integrations
Thymeleaf is also supported by:
- JRebel 5.2: http://zeroturnaround.com/software/jrebel/
Community
- User forums: http://forum.thymeleaf.org
- Issue tracking: Issue Tracking page
- Twitter: @thymeleaf
