Quantcast

Thymeleaf 3.0 is here :)

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Thymeleaf 3.0 is here :)

danielfernandez
Administrator

The moment has finally come: Thymeleaf 3.0.0 has just been published!

This is a huge moment for the project. Development on the 3.0 branch officially started in July 2014, but work on some parts of what today is Thymeleaf 3.0.0 started much earlier — like the new parser, AttoParser, which development started in late 2012.

So Thymeleaf 3 has meant a lot of effort, but the end product is something to be really proud of. Let's hope its improvements and new features will make your life easier, and your projects shine!


What's new?

Everything! No, really. From the inside, almost every line of code is new, because 3.0 is a complete rewrite of the engine.

Does this mean my 2.x templates won't work? No it doesn't mean that at all. In fact, 99% of template code made for 2.x is compatible with 3.0 without even touching it at all, though you might actually want to perform some modifications in order to benefit from the great improvements and new features in the new version.

Note however that most Java APIs have been changed (and improved!), which means that custom dialects and processors, custom resolvers, etc. will need to be updated in order to correctly work with Thymeleaf 3.0.

A very quick list of the new features:

  • Much, much better performance.
  • Full HTML5 support, no more XML-ized markup if you don't want to.
  • Ability to process TEXT (e.g. plain emails), not only markup.
  • Improved inlining capabilities. Don't like natural templates? don't do them.
  • Improved capabilities for fragment management / layouts.
  • Decoupled template logic. Pure HTML templates, all logic goes to a separate file.
  • Improved non-Servlet web integration, reactive-friendly operation.

Any docs I can read?

Yes. We have published a ten-minute migration guide that should be a nice start for most, containing a brief explanation on the different blocks of features in the new version.

Also, if you developed custom dialects for 2.x, you'll be interested in the "Extending Thymeleaf" tutorial, the only tutorial we've adapted to 3.0 so far. We decided to do this one first in order to ease the transition for integrators. Find it at our documentation page. Most of the example applications linked there have been updated to 3.0 too.

However, the rest of the documentation is still work-in-progress. We hope to be publishing new versions of all the remaining tutorials and articles along the next weeks. In the meantime, you can also have a look at these extensive descriptions of the major new features and capabilities in the form of GitHub tickets:


How to start using it

The binaries have been uploaded to the Maven/Gradle Central repositories, so you can just set 3.0.0.RELEASE as version in your build files and everything should run smoothly. For example:

    <dependency>
      <groupId>org.thymeleaf</groupId>
      <artifactId>thymeleaf</artifactId>
      <version>3.0.0.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.thymeleaf</groupId>
      <artifactId>thymeleaf-spring4</artifactId>
      <version>3.0.0.RELEASE</version>
      <scope>compile</scope>
    </dependency>

If you prefer, you can also download a complete binary distribution (together with all JavaDoc and all external dependencies) from the Bintray distribution repository.

More info at the project's Download Page.


JavaDoc


Published artifacts

The current artifacts have been published in 3.0.0.RELEASE version:

  • thymeleaf
  • thymeleaf-spring3
  • thymeleaf-spring4
  • thymeleaf-testing
  • thymeleaf-extras-springsecurity3
  • thymeleaf-extras-springsecurity4

Note also that thymeleaf-extras-conditionalcomments is not needed anymore, as its functionality is covered by Thymeleaf's core now, without needing any extensions.

Now, time to get some rest :)

Regards,
Daniel.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

Marco
hello, I am Marco, I am just using Thymeleaf 3.0 with spring 4 right now, but I encounter a problem when I use the ServletContextTemplateResolver, the log tells me that the ServletContextTemplateResolver can't be initialized, because it doesn't have default constructor, I really follow the tutorial's configuration, I don't known why.Does anyone help me resolving this problem? I will really appreciate your help.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

danielfernandez
Administrator
Hi Marco. Please have a look at our migration guide linked above.

If you are using Spring, you need to change ServletContextTemplateResolver with SpringResourceTemplateResolver. If you are note using Spring, you need to provide the ServletContextTemplateResolver with the ServletContext as a constructor argument.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

Marco
I will try it, thank you very much.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

mrusso
Thanks for all the hard work, this release looks great!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

branci
In reply to this post by danielfernandez
we have thymeleaf 2.1, and our templates are placed under src/main/resources/templates dir,
I am tring to migrate to thymeleaf3,
is it posible to leave my templates under the same dir or do I have to move then under /WEB-INF/templates dir ?


@Bean
    public ITemplateResolver templateResolver() {
         SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
         resolver.setApplicationContext(applicationContext);

         // dont work
         // resolver.setPrefix("/templates/");
         // dont work (without specifing prefix)
         // resolver.setPrefix(null);

         resolver.setTemplateMode(TemplateMode.HTML);
         return resolver;
     }
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

danielfernandez
Administrator
@branci

In web environments, the Spring resource locator defaults to ServletContext-based resolution, i.e. inside the "WEB-INF" folder. But this is a very flexible resource resolution mechanism, have a look at http://docs.spring.io/autorepo/docs/spring/4.2.x/spring-framework-reference/html/resources.html (specifically section 7.4).

In your case, most probably you'll have to specify "classpath:templates/" as a prefix.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

Delete
In reply to this post by danielfernandez
hello, I am delete ,I am just using Thymeleaf 3.0beta01 with spring 4 right now,I change Thymeleaf 3.0,
find Thymeleaf 3.0beta01 have org.thymeleaf.model.IElementAttributes but Thymeleaf 3.0 not to exist.

 I don't known Thymeleaf 3.0.0 Replace what
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

danielfernandez
Administrator
@Delete the IElementAttributes interface disappeared in newer betas. All of the information you could get from IElementAttributes in BETA01 you can now obtain it directly from the tags themselves, either directly (tag.getAttributeValue(name)) or by calling tag.getAttribute(name) and then querying the IAttribute interface returned there.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

dhrubo
In reply to this post by danielfernandez
The framework looks better than ever.
Kudos and congratulations.

One question - when can we expected R3.0 documentation?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

danielfernandez
Administrator
> One question - when can we expected R3.0 documentation?

Soon. We are working on it. Actually, note that the "Extending Thymeleaf" tutorial is already updated, and we are working on all the other tutorials and articles.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Thymeleaf 3.0 is here :)

dhrubo
Yes I noted that.
Thanks Daniel.
Your work is appreciated by the community.

Loading...