Skip to content

Fix: Resolve Thymeleaf 3.1.4+ TemplateProcessingException in variables.css (Issue #5251)#5264

Open
EIHEI2 wants to merge 1 commit intocodecentric:masterfrom
EIHEI2:fix-issue-47
Open

Fix: Resolve Thymeleaf 3.1.4+ TemplateProcessingException in variables.css (Issue #5251)#5264
EIHEI2 wants to merge 1 commit intocodecentric:masterfrom
EIHEI2:fix-issue-47

Conversation

@EIHEI2
Copy link
Copy Markdown

@EIHEI2 EIHEI2 commented Apr 15, 2026

Description

This PR fixes the TemplateProcessingException that occurs with Thymeleaf 3.1.4.RELEASE when processing the variables.css template.

Problem

Thymeleaf 3.1.4+ introduced stricter security restrictions that forbid bean references (@cssColorUtils) in CSS templates, causing the following error:

Solution

  1. Added a model attribute to that pre-computes RGB values from the theme palette
  2. Updated template to use the pre-computed map instead of calling directly
  3. Added bean configuration for better compatibility

Changes

  • : Added dependency and model attribute method
  • : Updated template expressions to use instead of bean method calls
  • : Added bean configuration

Testing

The fix avoids bean references in the template while maintaining the same functionality. The RGB values are computed once per request in the controller instead of per-variable in the template.

Fixes #5251

…estriction

- Add cssColors model attribute to UiController with pre-computed RGB values
- Update variables.css template to use cssColors instead of @cssColorUtils bean reference
- Add SpringStandardDialect bean configuration for compatibility

This fixes the TemplateProcessingException caused by Thymeleaf 3.1.4.RELEASE
which forbids bean references (@cssColorUtils) in CSS templates.
@EIHEI2 EIHEI2 requested a review from a team as a code owner April 15, 2026 02:04
@ModelAttribute(value = "cssColors", binding = false)
public Map<String, String> getCssColors() {
var palette = uiSettings.getTheme().getPalette();
return Map.of(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the values here come from the configuration, I would personally just compute this map once in the constructor when the controller is created and just reuse that value every time the endpoint gets called.

That's just a small optimisation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

org.thymeleaf.exceptions.TemplateProcessingException in variables.css

2 participants