Skip to content

Latest commit

 

History

History
 
 

jooby-pebble

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

pebble

Pebble a lightweight but rock solid Java templating engine.

exports

dependency

<dependency>
 <groupId>org.jooby</groupId>
 <artifactId>jooby-pebble</artifactId>
 <version>1.0.0.CR8</version>
</dependency>

usage

{
  use(new Pebble());

  get("/", req -> Results.html("index").put("model", new MyModel());

  // or Pebble API
  get("/pebble-api", req -> {

    PebbleEngine pebble = req.require(PebbleEngine.class);
    PebbleTemplate template = pebble.getTemplate("template");
    template.evaluate(...);
  });

}

Templates are loaded from root of classpath: / and must end with: .html file extension.

template loader

Templates are loaded from the root of classpath and must end with .html. You can change the default template location and extensions too:

{
  use(new Pebble("templates", ".pebble"));

}

template cache

Cache is OFF when env=dev (useful for template reloading), otherwise is ON.

Cache is backed by Guava and the default cache will expire after 200 entries.

If 200 entries is not enough or you need a more advanced cache setting, just set the pebble.cache option:

pebble.cache = "expireAfterWrite=1h;maximumSize=200"

See com.google.common.cache.CacheBuilderSpec.

tag cache

It works like template cache, except the cache is controlled by the property: pebble.tagCache

advanced configuration

Advanced configuration if provided by callback:

{
  use(new Pebble().doWith(pebble -> {

    pebble.extension(...);
    pebble.loader(...);
  }));

}

That's all folks! Enjoy it!!!