Skip to content
This repository

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

Closed
balteo opened this Issue September 05, 2012 · 6 comments

6 participants

balteo Emanuel Rabina ashley7070 Pid Jan Boonen Daniel Fernández
balteo

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:
http://forum.thymeleaf.org/Using-Spring-s-theme-resolvers-and-themes-with-a-Thymeleaf-template-td4025026.html

ashley7070

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

Pid

Seems like a smashing idea.

Jan Boonen

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?

Emanuel Rabina
Collaborator

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.

eg:

<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?

Daniel Fernández

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

Emanuel Rabina
Collaborator

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.

Emanuel Rabina ultraq closed this March 17, 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.