Thymeleaf in JARs

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Thymeleaf in JARs

Paul Wilson
Hi there,

Something that isn't mentioned in the feature list is whether Thymeleaf templates can be loaded from JAR files, something that is not possible with JSPs. Might be a nice selling point if it does?

Regards,
Paul
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf in JARs

danielfernandez
Administrator
Hi,

Thymeleaf DOES indeed allow your templates to live inside a .jar file. In fact, it allows your templates to live wherever you want, as long as you provide an ITemplateResolver implementation that is able to open an InputStream on them.

Out-of-the-box implementations for this interface include getting templates from anywhere in the classpath (ClassLoaderTemplateResolver), from files anywhere in your file system (FileTemplateResolver) from URLs of any kind (UrlTemplateResolver) and also from the ServletContext (ServletContextTemplateResolver), only being this last one the equivalent to JSP template resolution.

In order to get your templates from a .jar file, ClassLoaderTemplateResolver should be the better option.

Adding a comment about this in the feature list shouldn't do any harm, you're right ;-)

Regards,
Daniel.