1. Thymeleaf

Thymeleaf templates template engine module.

1.1. Usage

1) Add the dependency:


2) Write your templates inside the views folder

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
  Hello <span th:text="${name}">World</span>

3) Install and use thymeleaf templates

import io.jooby.thymeleaf.ThymeleafModule;

  install(new ThymeleafModule());

  get("/", ctx -> {
    return new ModelAndView("index.html")
        .put("name", "Jooby");

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

1.2. Templates Location

Template location is set to views. The views folder/location is expected to be at the current user directory or at root of classpath.

You can override the default location by setting the templates.path property in the application configuration file or programmatically at creation time.

1.3. Template Cache

The thymeleaf module turn off cache while running in dev or test environment. For any other environment it use the default cache settings.

1.4. Configuration

Advanced configuration options are available by providing an instance of TemplateEngine

import io.jooby.thymeleaf.ThymeleafModule;

  TemplateEngine templateEngine = new TemplateEngine();
  // configure as need it

  install(new ThymeleafModule(templateEngine));

There is a builder function to create a TemplateEngine: create().