Skip to content

Using Spring's theme resolvers and themes with a Thymeleaf template [enhancement] #75

balteo opened this Issue Sep 5, 2012 · 6 comments
balteo commented Sep 5, 2012

It would be a interesting enhancement to be able to use Spring's theme resolvers and themes in a Thymeleaf template.

Further information available on Thymeleaf's forum:


This is the only reason I am not using thymeleaf at the moment. We rely heavilly on spring:theme tag for multi branding.

pidster commented Oct 25, 2012

Seems like a smashing idea.

boonen commented Mar 10, 2013

This issue is already open for more than 6 months now. Any idea when it is planned to be implemented (I'd really love to use this feature in thymeleaf...). Perhaps someone can point in the right direction to start an implementation?

The Thymeleaf Open Source Project member
ultraq commented Mar 11, 2013

I haven't used Spring themes before, but from what I've read and looking at the source code of the JSP tag, I think what needs to happen is that we create a new utility object (eg: call it spring and it has a method theme()) that accepts a single parameter (the code value, which is a key into the theme's properties file), and returns the value from the properties file, writing it into the document structure.


<link rel="stylesheet" href="${#spring.theme('styleSheet')}" type="text/css"/>

Would become:

<link rel="stylesheet" href="themes/MyTheme.css" type="text/css"/>

Because the theme properties file had:

styleSheet = themes/MyTheme.css

All other Spring theme mechanisms (theme switching, interceptors, etc) should work without any change as they all go through Spring's DispatcherServlet.

@danielfernandez I can probably put together some proof-of-concept this week. I also think this change would be better suited to the thymeleaf-spring3 project, in which case a utility object called spring is probably a bad name. Maybe theme with the method name of code() instead?

The Thymeleaf Open Source Project member

Looks like a very nice idea to me, Emanuel. Maybe #themes.code(...) or even #themes.theme(...) would be also nice possibilities...

@ultraq ultraq was assigned Mar 14, 2013
The Thymeleaf Open Source Project member
ultraq commented Mar 18, 2013

Checked in code for a #themes.code(...) expression object as part of the thymeleaf-spring3 project, will be in version 2.0.17. Also did work on the Eclipse plugin to add support for this new object/method in version 2.0.1.

@ultraq ultraq closed this Mar 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.