diff --git a/pom.xml b/pom.xml
index fe75472..7d583bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,6 +82,11 @@
hibernate-validator
8.0.0.Final
+
+ io.pebbletemplates
+ pebble
+ 3.2.1
+
diff --git a/src/main/java/run/undead/javalin/example/Server.java b/src/main/java/run/undead/javalin/example/Server.java
index 935fdf7..7eb9020 100644
--- a/src/main/java/run/undead/javalin/example/Server.java
+++ b/src/main/java/run/undead/javalin/example/Server.java
@@ -29,6 +29,7 @@ public static void main(String[] args) {
), undeadConf)
// use the UndeadJavalin instance to register Undead Views to routes
.undead("/count", new UndeadCounter())
+ .undead("/count/pebble", new UndeadCounterPebble())
.undead("/count/{start}", new UndeadCounter())
.undead("/dashboard", new UndeadSalesDashboard())
.undead("/user/new", new UndeadUserForm())
diff --git a/src/main/java/run/undead/javalin/example/view/UndeadCounterPebble.java b/src/main/java/run/undead/javalin/example/view/UndeadCounterPebble.java
new file mode 100644
index 0000000..666ff13
--- /dev/null
+++ b/src/main/java/run/undead/javalin/example/view/UndeadCounterPebble.java
@@ -0,0 +1,49 @@
+package run.undead.javalin.example.view;
+
+import io.pebbletemplates.pebble.PebbleEngine;
+import run.undead.context.Context;
+import run.undead.event.UndeadEvent;
+import run.undead.pebble.PebbleTemplateAdaptor;
+import run.undead.template.UndeadTemplate;
+import run.undead.view.Meta;
+import run.undead.view.View;
+
+import java.util.Map;
+
+public class UndeadCounterPebble implements View {
+ private Integer count;
+ private PebbleTemplateAdaptor adaptor = new PebbleTemplateAdaptor(new PebbleEngine.Builder()
+ .build());
+
+ public UndeadCounterPebble() {
+ this.count = 0;
+ }
+
+ @Override
+ public void mount(Context context, Map sessionData, Map params) {
+ if (params.get("start") != null) {
+ this.count = Integer.parseInt((String) params.get("start"));
+ } else {
+ this.count = 0;
+ }
+ }
+
+ @Override
+ public void handleEvent(Context context, UndeadEvent event) {
+ if (event.type().equals("inc")) {
+ this.count++;
+ } else if (event.type().equals("dec") && this.count > 0) {
+ this.count--;
+ }
+ }
+
+ @Override
+ public UndeadTemplate render(Meta meta) {
+ try {
+ return adaptor.render("count.html", Map.of("count", this.count));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/src/main/java/run/undead/pebble/PebbleTemplateAdaptor.java b/src/main/java/run/undead/pebble/PebbleTemplateAdaptor.java
new file mode 100644
index 0000000..880a00c
--- /dev/null
+++ b/src/main/java/run/undead/pebble/PebbleTemplateAdaptor.java
@@ -0,0 +1,72 @@
+package run.undead.pebble;
+
+import io.pebbletemplates.pebble.PebbleEngine;
+import io.pebbletemplates.pebble.template.PebbleTemplate;
+import run.undead.template.UndeadTemplate;
+
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class PebbleTemplateAdaptor {
+
+ private final PebbleEngine engine;
+
+ public PebbleTemplateAdaptor() {
+ this(new PebbleEngine.Builder().build());
+ }
+ public PebbleTemplateAdaptor(PebbleEngine engine) {
+ this.engine = engine;
+ }
+
+ public UndeadTemplate render(String template, Map data) throws Exception {
+ PebbleTemplate compiledTemplate = engine.getTemplate(template);
+
+ var writer = new StringTemplateWriter();
+ compiledTemplate.evaluate(writer, data);
+ return new UndeadTemplate(writer.toStringTemplate(), false);
+ }
+
+ class StringTemplateWriter extends Writer {
+ private final List fragments = new ArrayList<>();
+ private final List