Your SlideShare is downloading. ×
Thymeleaf: improving your Spring view layer with natural templates
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Thymeleaf: improving your Spring view layer with natural templates


Published on

Speaker: Emanuel Rabina …

Speaker: Emanuel Rabina
With the disconnect between the languages of the web (HTML, CSS, Javascript) and the languages of the server (Java, Groovy, Scala, etc), many libraries and frameworks have been invented over the years to fill this void, often resulting in views filled with back-end code, views filled with specialized syntaxes, or even the invention of completely new view languages abstractions; all for the purpose of transforming our server-side ideas into HTML, and few of which actually look like the HTML that it ends up as.
Enter Thymeleaf - a templating framework that uses HTML to create good old HTML.
In this presentation, you'll be introduced to Thymeleaf, some of its features, how you can use it in your Spring web projects, the growing ecosystem being developed around it, and how it uses natural templates to keep the web designer on your team, and inside each and every one of us, happy.

Published in: Technology, Business

  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Thymeleaf Improving your Spring View Layer with Natural Templates Emanuel Rabina - @u1traq © 2013 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 2. Thymeleaf @thymeleaf
  • 3. Background
  • 4. <p> Hello World! </p>
  • 5.
  • 6.
  • 7. <b> bold </b> <i> italic </i> <blink> ... </blink>
  • 8. Dynamic Web • Perl • JSP • PHP • ASP • GSP • anything-that-ends-with-P
  • 9. Dynamic Web • Perl • JSF • JSP • GWT • PHP • ASP • GSP • anything-that-ends-with-P
  • 10. <h:panelGrid> ... </h:panelGrid>
  • 11. The Language Barrier
  • 12. Client-side languages Server-side languages ? Java HTML C# CSS Perl JavaScript Scala Ruby Groovy
  • 13.
  • 14. PHP JSP ASP.NET HTML Ruby on Rails GSP CGI ScalaTemplates CFM
  • 15.
  • 16. Enter Thymeleaf
  • 17. Natural Templates “The template can be a document as valid as the final result, the engine syntax doesn’t break the document structure.”
  • 18. Natural Templates
  • 19. (JSP example)
  • 20. (Thymeleaf example)
  • 21. Natural Templates JSP opened w/ browser Thymeleaf opened w/ browser
  • 22. <% ... %> <c:forEach...> <?php ... ?> <g:each...> <%= ... %> <ui:repeat...> @for <cfloop...> #foreach
  • 23. th:attr th:fragment th:attrappend th:if th:attrprepend th:include th:case th:inline th:classappend th:object th:each th:unless
  • 24. Natural Templates • Quick prototyping • Design in the browser • Encouraged to add text and content • No need to start an app server • It’s HTML
  • 25. Extending Thymeleaf
  • 26. Dialects • Prefix • Processors • Expression objects th each, text, utext, ... #dates, #arrays, ...
  • 27. public class MyDialect extends AbstractDialect implements IExpressionEnhancingDialect { public Map<String,Object> getAdditionalExpressionObjects(...); public String getPrefix(); public Set<IProcessor> getProcessors(); }
  • 28. public class MyProcessor extends AbstractAttrProcessor { public MyProcessor(); // Constructor public int getPrecedence(); public ProcessorResult processAttribute( Arguments arguments, Element element, String attributeName); }
  • 29. (Custom dialect example)
  • 30. Working with Spring
  • 31. (Spring example)
  • 32. Ecosystem
  • 33. Early 2012
  • 34. Extras / ‘official’ •Eclipse Plugin Content assist (autocomplete/suggestions) support in Eclipse •Tiles 2 Use Apache Tiles 2 to compose your templates •Spring Security 3 Adds attribute processors and utility objects to use Spring Security expressions •Conditional Comments Processing of all the kinds of Internet Explorer conditional comments
  • 35. Community •Thymol Includes other pages referenced with th:include when viewed statically •Dandelion DataTables Ridiculously customizable tables for the display of data •Layout Dialect Inheritance-based page creation, like SiteMesh or JSF + Facelets
  • 36. Community And many more: •modules for the Play Framework •a JRebel plugin option to not cache in development mode •integration with Apache Shiro •client-side form validation using your JSR-303 Bean Validation annotations •runtime optimization of JS/CSS resources •creation of arbitrary data-* attributes •Thymeleaf + Spring MVC Maven archetype •...
  • 37. Who’s using Thymeleaf?
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. How companies have used Thymeleaf • Migrate from other technologies • Take advantage of a Spring-integrated technology (thus making use of the Spring developer community) • Improve workflow / communication • Allow front-end specialists to really hack the view
  • 45. ??? The future of Thymeleaf
  • 46. Future plans • Attoparser • data-* attribute processors • Template fragments as variables • Template-only comments! :) • ‘TEXT’ template mode • Spring/Global formatters • De-coupling processing instructions from templates
  • 47. Learn More. Stay Connected. Visit our website: Follow us on Twitter: @thymeleaf Talk to us on Twitter: @springcentral Find session replays on YouTube: