Über Thymeleaf

Dateitypen und Dialekte

Mit Thymeleaf können (unter anderem) die folgenden Dateitypen verarbeitet werden:

  • XML
  • XHTML
  • HTML5

In Thymeleaf kann man eigene Dialekte definieren. In den meisten Fällen dürfte der Standard Dialect aber ausreichen

Hinweis bezüglich Spring

The official thymeleaf-spring3 and thymeleaf-spring4 integration packages both define a dialect called the “SpringStandard Dialect”, mostly equivalent to the Standard Dialect but with small adaptations to make better use of some features in Spring Framework (for example, by using Spring Expression Language instead of Thymeleaf’s standard OGNL). So if you are a Spring MVC user you are not wasting your time, as almost everything you learn here will be of use in your Spring applications.

Statische Templates

Thymeleaf hat einen entscheidenden Vorteil (z.B. gegenüber JSP):

Thymeleaf allows browsers to correctly display XHTML/HTML5 template files even before being processed, because they will simply ignore the additional attributes. ( browsers ignore all attributes they don’t understand, like th:text)

Verwendung (Beispiel)

<input type="text" name="userName" value="James Carrot" th:value="${user.name}" />

a value attribute in it (“James Carrot”, in this case) that will be displayed when the prototype is statically opened

Sourcecode für ein Beispielprojekt

Der komplette Sourcecode für dieses und alle weiteren Kapitel befindet sich auf GitHub.

Quelle

Alle zitierten Textstellen der folgenden Kapitel stammen aus der Thymeleaf Dokumentation

results matching ""

    No results matching ""