Class ThymeleafModule

java.lang.Object
io.jooby.thymeleaf.ThymeleafModule
All Implemented Interfaces:
io.jooby.Extension

public class ThymeleafModule extends Object implements io.jooby.Extension
Thymeleaf module: https://jooby.io/modules/thymeleaf.

Usage:


 {

   install(new ThymeleafModule());

   get("/", ctx -> {
     User user = ...;
     return new ModelAndView("index.html")
         .put("user", user);
   });
 }
 
The template engine looks for a file-system directory: views in the current user directory. If the directory doesn't exist, it looks for the same directory in the project classpath.

Template engine supports the following file extensions: .thl, .thl.html and .html.

You can specify a different template location:


 {

    install(new ThymeleafModule("mypath"));

 }
 
The mypath location works in the same way: file-system or fallback to classpath.

Direct access to TemplateEngine is available via require call:


 {

   TemplateEngine engine = require(TemplateEngine.class);

 }
 
Complete documentation is available at: https://jooby.io/modules/thymeleaf.
Since:
2.0.0
Author:
edgar
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Utility class for creating TemplateEngine instances.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates module module using the default template path: views.
    ThymeleafModule(String templatesPath)
    Creates module which look at the given path.
    ThymeleafModule(Path templatesPath)
    Creates module which look at the given path.
    ThymeleafModule(org.thymeleaf.TemplateEngine templateEngine)
    Creates a new module uses the given template engine.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new thymeleaf builder.
    void
    install(io.jooby.Jooby application)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.jooby.Extension

    lateinit
  • Constructor Details

    • ThymeleafModule

      public ThymeleafModule(@NonNull org.thymeleaf.TemplateEngine templateEngine)
      Creates a new module uses the given template engine. You can create a default engine using the create() method.
      Parameters:
      templateEngine - Template engine.
    • ThymeleafModule

      public ThymeleafModule(@NonNull String templatesPath)
      Creates module which look at the given path. It first look at the file-system or fallback to classpath.
      Parameters:
      templatesPath - Template path.
    • ThymeleafModule

      public ThymeleafModule(@NonNull Path templatesPath)
      Creates module which look at the given path.
      Parameters:
      templatesPath - Template path.
    • ThymeleafModule

      public ThymeleafModule()
      Creates module module using the default template path: views. It first look at the file-system or fallback to classpath.
  • Method Details

    • install

      public void install(@NonNull io.jooby.Jooby application)
      Specified by:
      install in interface io.jooby.Extension
    • create

      @NonNull public static ThymeleafModule.Builder create()
      Creates a new thymeleaf builder.
      Returns:
      A builder.