Fork me on GitHub

Pebble is a modern template engine for Java.


1) Add the pippo-pebble dependency to your pom.xml:


2) Start writing Pebble templates in the templates folder of your application.
Note: The default file extension of a Pebble template is .peb and it has to be omitted from your templates and your Pippo Java code. The default location (=base path) of the template files is src/main/resources/templates. If you use template inheritance or partial templates then you have to omit the base path! Currently the default extension of Pebble templates cannot be changed.


This engine includes some useful Pippo integration features and conveniences like…


You can access your translation resources using the i18n helper.

{{ i18n('') }}

You can supply arguments to your MessageFormat translation resources too.

{{ i18n('', 'arg1', 'arg2') }}
prettytime (relative time)

The pippo-pebble module supports automatically localized prettytime out-of-the-box and it is very easy to use.

Assuming you are providing a java.util.Date instance to prettyTime…

{{ myDate | prettyTime }}

Will produce something like…

3 days ago

You can also automatically format localized dates using standard Java date format patterns.

{{ myDate | formatTime('short') }}
{{ myDate | formatTime('medium') }}
{{ myDate | formatTime('long') }}
{{ myDate | formatTime('full') }}
{{ myDate | formatTime('HH:mm') }}
{{ myDate | formatTime('dd-MM-yyyy HH:mm') }}

webjarsAt & publicAt

The pippo-pebble module supports context-aware url generation for your classpath resources using the webjarsAt and publicAt extensions.

<!-- Stylesheets -->
<link href="{{ webjarsAt('bootstrap/3.3.1/css/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ webjarsAt('font-awesome/4.2.0/css/font-awesome.min.css') }}" rel="stylesheet">
<link href="{{ publicAt('css/style.css') }}" rel="stylesheet">

<!-- Scripts -->
<script src="{{ webjarsAt('jquery/1.11.1/jquery.min.js') }}"></script>
<script src="{{ webjarsAt('bootstrap/3.3.1/js/bootstrap.min.js') }}"></script>
<script src="{{ publicAt('js/main.js') }}"></script>

NOTE: Use of these methods require that you have registered a WebjarsResourceRoute and/or a PublicResourceRoute.

public class MyApplication extends Application {

    protected void onInit() {
        // add routes for static content
        // add other routes

Pebble and AngularJS both use the double-brace notation.

The pippo-pebble module comes with out-of-the-box support for the following syntax:

{{ng something | or | other}}

Anything after the ng will be re-injected into the template during the compilation phase.

Error Templates

The pippo-pebble module will render special templates for routing problems and exceptions. You may override these templates within your own application.

  • templates/pippo/404notFound.peb
  • templates/pippo/500interalError.peb