Pebble templates for Jooby.
1) Add the dependency:
.
2) Write your templates inside the views folder
views/index.peb
<p> Hello {{name}}! </p>3) Install and use pebble templates
Java
import io.jooby.pebble.PebbleModule;
{
install(new PebbleModule());
get("/", ctx -> {
return new ModelAndView("index.peb")
.put("name", "Jooby");
});
}Kotlin
import io.jooby.pebble.PebbleModule
{
install(PebbleModule())
get("/") {
ModelAndView("index.peb")
.put("name", "Jooby")
}
}Template engine supports the following file extensions: .peb, .pebble and .html.
Default 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.
Custom Pebble object can be provided it programmatically:
Java
import io.jooby.pebble.PebbleModule;
{
// Apply custom configuration via builder
PebbleEngine.Builder builder = PebbleModule.create()
.setTemplatesPath("template")
.build(getEnvironment());
install(new PebbleModule(builder));
}Kotlin
import io.jooby.pebble.PebbleModule
{
val builder = PebbleModule.create()
.setTemplatesPath("template")
.build(getEnvironment())
install(PebbleModule(builder))
}