thymeleaf / thymeleaf-spring

Thymeleaf integration module for Spring
http://www.thymeleaf.org
Apache License 2.0
435 stars 157 forks source link

Support for Feature Flags (e.g. Spring Profile annotations) #325

Open goodale opened 6 months ago

goodale commented 6 months ago

What is the best practice method to integrate Spring Profiles into Thymeleaf views to conditionally alter components in the UI? It would be possible to add profile data into the model provide by the controller but ideally (I think?) there would be direct Thymeleaf tag support for profiles.

ultraq commented 6 months ago

Not entirely sure if it's what you're after, but a while ago I wrote a dialect to conditionally render Thymeleaf templates based on the active Spring Profile: https://github.com/ultraq/thymeleaf-spring-environment-dialect If rendering different markup isn't what you're after, then you can check the source code of the processors to see how it gets access to the active Spring Profile so you can do what you need.