public class HandlebarsModule extends Object implements Extension
{
install(new HandlebarsModule());
get("/", ctx -> {
User user = ...;
return new ModelAndView("index.hbs")
.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.
You can specify a different template location:
{
install(new HandlebarsModule("mypath"));
}
The mypath location works in the same way: file-system or fallback to classpath.
Template engine supports the following file extensions: .ftl,
.ftl.html and .html.
Direct access to Handlebars is available via require call:
{
Handlebars hbs = require(Handlebars.class);
}
Complete documentation is available at: https://jooby.io/modules/handlebars.| Modifier and Type | Class and Description |
|---|---|
static class |
HandlebarsModule.Builder
Utility class for creating
Handlebars instances. |
| Constructor and Description |
|---|
HandlebarsModule()
Creates a new handlebars module using the default path:
views. |
HandlebarsModule(com.github.jknack.handlebars.Handlebars handlebars)
Creates a new handlebars module.
|
HandlebarsModule(Path templatesPath)
Creates a new handlebars module.
|
HandlebarsModule(String templatesPath)
Creates a new handlebars module.
|
| Modifier and Type | Method and Description |
|---|---|
static HandlebarsModule.Builder |
create()
Creates a new freemarker builder.
|
void |
install(Jooby application) |
public HandlebarsModule(@Nonnull com.github.jknack.handlebars.Handlebars handlebars)
handlebars - Handlebars instance to use.public HandlebarsModule(@Nonnull String templatesPath)
templatesPath - Template location to use. First try to file-system or fallback to
classpath.public HandlebarsModule(@Nonnull Path templatesPath)
templatesPath - Template location to use. First try to file-system or fallback to
classpath.public HandlebarsModule()
views.Copyright © 2020. All rights reserved.