Blade uses a built-in template engine by default. Templates are expected to be in the templates directory.
Default Template Usage
Use ctx.attribute(key, value) to pass data to the template, then call ctx.render("filename.html").
Using Jetbrick Template Engine
To use an alternative engine like Jetbrick, implement the BladeLoader interface and register the engine in the load method.
// Default usage
Blade.create().get("/hello", ctx -> {
ctx.attribute("name", "hellokaton");
ctx.render("hello.html");
}).start(Hello.class, args);
// Customizing with Jetbrick
@Bean
public class TemplateConfig implements BladeLoader {
@Override
public void load(Blade blade) {
blade.templateEngine(new JetbrickTemplateEngine());
}
}