Monday, November 19, 2012

Thymeleaf & Magnolia: a prototype

I've been working with magnolia for a while now, and I tend to like it's simplicity. But I don't like freemarker and even less JSP's. So I tried to integrate thymeleaf with magnolia, which wasn't as straightforward as expected.

Magnolias rendering engine API is based on working on a character stream for creating it's output. It does so when including areas & components, which didn't work wout with thymeleaf, that does includes based on it's internal DOM representation. So what I've created by now is a little hackish, I started with thymeleaf's include processor and mimik'ed the spring controller invocation from blossom and provided the magnolia content/context objects locally to the dom for rendering.

I had to clone some code fragments from magnolia and spring (cruel final and private api), but it's working like a charm.

You can find the code on github, should be a good starting point if you want to use thymeleaf with magnolia.