== Handlebars

https://github.com/jknack/handlebars.java[Handlebars templates] for Jooby.

=== Usage

1) Add the dependency:

[dependency, artifactId="jooby-handlebars"]
.

2) Write your templates inside the `views` folder

.views/index.hbs
[source, html]
----
<p> Hello {{name}}! </p>
----

3) Install and use freemarker templates

.Java
[source, java, role="primary"]
----
import io.jooby.handlebars.HandlebarsModule;

{
  install(new HandlebarsModule());

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

.Kotlin
[source, kt, role="secondary"]
----
import io.jooby.handlebars.HandlebarsModule

{
  install(HandlebarsModule())
  
  get("/") {
    ModelAndView("index.hbs")
        .put("name", "Jooby")
  }
}
----

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

=== 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.

=== Template Cache

The handlebars module turn off cache while running in `dev` or `test` environment. For any other
environment it use https://github.com/jknack/handlebars.java#the-cache-system[HighConcurrencyTemplateCache]

=== Custom configuration

Custom Handlebars object can be provided it programmatically:

.Java
[source, java, role="primary"]
----
import io.jooby.handlebars.HandlebarsModule;

{
  Handlebars handlebars = new Handlebars();
  
  // Apply custom configuration

  install(new HandlebarsModule(handlebars));
}
----

.Kotlin
[source, kt, role="secondary"]
----
import io.jooby.handlebars.HandlebarsModule

{
  val handlebars = Handlebars()
 
  // Apply custom configuration

  install(HandlebarsModule(handlebars))
}
----
