Skip to content

Commit 83732c5

Browse files
committed
Improve Templates section (#73)
1 parent 3000f5c commit 83732c5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

_posts/2015-03-17-templates.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,36 @@ public class CrudApplication extends Application {
140140
}
141141
```
142142

143+
You can extend very easy the template engine and add/modify features.
144+
See below how you can add a `Trimou` custom template engine in your application.
145+
You can create the `MyTrimouTemplateEngine` class, like this:
146+
147+
```java
148+
public class MyTrimouTemplateEngine extends TrimouTemplateEngine {
149+
150+
@Override
151+
protected void init(Application application, Configuration configuration) {
152+
// your custom logic here
153+
}
154+
155+
}
156+
```
157+
158+
In your `Application`/`ControllerApplication` sub-class, you can do the following:
159+
160+
```java
161+
public class PippoApplication extends ControllerApplication {
162+
163+
@Override
164+
protected void onInit() {
165+
setTemplateEngine(new MyTrimouTemplateEngine());
166+
}
167+
168+
}
169+
```
170+
171+
If you want how to add a new function `Filter`(MyUpperFiler) in `PebbleTemplateEngine` please see [this](https://github.com/pippo-java/pippo/pull/213).
172+
143173
In Pippo, each builtin template engine comes with special templates for routing problems and exceptions.
144174
See below the special templates that come by default with `pippo-freemarker`
145175
```bash

0 commit comments

Comments
 (0)