1. Pebble
Pebble templates for Jooby.
1.1. Usage
1) Add the dependency:
Maven
Gradle
<dependency>
<groupId>io.jooby</groupId>
<artifactId>jooby-pebble</artifactId>
<version>3.5.3</version>
</dependency>
2) Write your templates inside the views
folder
views/index.peb
<p> Hello {{name}}! </p>
3) Install and use pebble templates
Java
Kotlin
import io.jooby.pebble.PebbleModule;
{
install(new PebbleModule());
get("/", ctx -> {
return new ModelAndView("index.peb")
.put("name", "Jooby");
});
}
Template engine supports the following file extensions: .peb
, .pebble
and .html
.
1.2. Templates Location
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.
1.3. Template Cache
The pebble module turn off cache while running in dev
or test
environment.
1.4. Custom configuration
Custom Pebble object can be provided it programmatically:
Java
Kotlin
import io.jooby.pebble.PebbleModule;
{
// Apply custom configuration via builder
PebbleEngine.Builder builder = PebbleModule.create()
.setTemplatesPath("template")
.build(getEnvironment());
install(new PebbleModule(builder));
}