1. Handlebars

1.1. Usage

1) Add the dependency:

Maven
Gradle
<dependency>
  <groupId>io.jooby</groupId>
  <artifactId>jooby-handlebars</artifactId>
  <version>3.5.3</version>
</dependency>

2) Write your templates inside the views folder

views/index.hbs
<p> Hello {{name}}! </p>

3) Install and use freemarker templates

Java
Kotlin
import io.jooby.handlebars.HandlebarsModule;

{
  install(new HandlebarsModule());

  get("/", ctx -> {
    return new MapModelAndView("index.hbs")
        .put("name", "Jooby");
  });
}

Template engine supports the following file extensions: .hbs, .hbs.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 handlebars module turn off cache while running in dev or test environment. For any other environment it use HighConcurrencyTemplateCache

1.4. Custom configuration

Custom Handlebars object can be provided it programmatically:

Java
Kotlin
import io.jooby.handlebars.HandlebarsModule;

{
  Handlebars handlebars = new Handlebars();

  // Apply custom configuration

  install(new HandlebarsModule(handlebars));
}