Templates inheritance with Freemarker

Viewed 253

I'm starting a new progect usign Freemarker as server-side template engine.

I often use Thymeleaf in my web project, adding Layout Dialect to create a hierarchy of template: starting from a main layout and decorating it with specific section for every page needed in my project.

I haven't used Freemarker very often, but, if I'm not wrong, it only implements templating by include/import.

Is there a way to use something like Thymeleaf Layout Dialect also with Freemarker?

In an old project I used Apache Tiles to do something similar, but now the project is retired. Is there any recent alternative?

1 Answers

There's no "inheritance" like in some other template engines. The main way of reusing pieces is with #macro (and #nested) in FreeMarker. Also note that macros are first class values, so they can be passed to other macros as arguments.

Related