jade

jade

jade4j’s intention is to be able to process jade templates in Java without the need of a JavaScript environment, while being fully compatible with the original jade syntax.

exports

dependency

<dependency>
 <groupId>org.jooby</groupId>
 <artifactId>jooby-jade</artifactId>
 <version>1.1.3</version>
</dependency>

usage

{
  use(new Jade());

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

  // or via API
  get("/jade-api", req -> {
    JadeConfiguration jade = require(JadeConfiguration.class);
    JadeTemplate template = jade.getTemplate("index");
    template.renderTemplate(...);
  });

}

Templates are loaded from root of classpath: / and must ends with: .jade file extension.

request locals

A template engine has access to request locals (a.k.a attributes). Here is an example:

{
  use(new Jade());

  get("*", req -> {
    req.set("foo", bar);
  });
}

Then from template:

#{foo}

template loader

Templates are loaded from the root of classpath and must ends with .jade. You can change the extensions too:

{
  use(new Jade(".html"));
}

Keep in mind if you change it file name must ends with: .html.jade.

template cache

Cache is OFF when application.env = dev (useful for template reloading), otherwise is ON and does not expire, unless you explicitly set jade.caching.

pretty print

Pretty print is on when application.env = dev, otherwise is off, unless unless you explicitly set jade.prettyprint.