Class PebbleModule

java.lang.Object
io.jooby.pebble.PebbleModule
All Implemented Interfaces:
io.jooby.Extension

public class PebbleModule extends Object implements io.jooby.Extension
Pebble module: https://jooby.io/modules/pebble.

Usage:


 {

   install(new PebbleModule());

   get("/", ctx -> {
     User user = ...;
     return new ModelAndView("index.peb")
         .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 PebbleModule("mypath"));

 }
 

The mypath location works in the same way: file-system or fallback to classpath.

Template engine supports the following file extensions: .peb, .pebble and .html.

Direct access to PebbleEngine.Builder is available via require call:


 {

   PebbleEngine.Builder builder = require(PebbleEngine.Builder.class);

 }
 

Complete documentation is available at: https://jooby.io/modules/pebble.

Since:
2.0.0
Author:
sojin
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Utility class for creating PebbleModule instances.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new PebbleModule module using the default path: views.
    PebbleModule(io.pebbletemplates.pebble.PebbleEngine.Builder builder)
    Creates a new pebble module.
    PebbleModule(String templatesPath)
    Creates a new PebbleModule module.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new PebbleModule.Builder.
    void
    install(io.jooby.Jooby application)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.jooby.Extension

    lateinit
  • Constructor Details

    • PebbleModule

      public PebbleModule(@NonNull io.pebbletemplates.pebble.PebbleEngine.Builder builder)
      Creates a new pebble module.
      Parameters:
      builder - PebbleEngine.Builder instance to use.
    • PebbleModule

      public PebbleModule(@NonNull String templatesPath)
      Creates a new PebbleModule module.
      Parameters:
      templatesPath - Template location to use. First try to file-system or fallback to classpath.
    • PebbleModule

      public PebbleModule()
      Creates a new PebbleModule module using the default path: views.
  • Method Details

    • install

      public void install(@NonNull io.jooby.Jooby application) throws Exception
      Specified by:
      install in interface io.jooby.Extension
      Throws:
      Exception
    • create

      @NonNull public static PebbleModule.Builder create()
      Creates a new PebbleModule.Builder.
      Returns:
      A builder.