-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Hi, thanks for this excellent project.
I'd like to request support for Thymeleaf template syntax preservation.
Background
minify-html already supports preserving several template syntaxes through:
preserve_brace_template_syntaxpreserve_chevron_percent_template_syntax
However, Thymeleaf uses different markers that aren't currently recognized.
The Problem
Aggressive minification can silently break Thymeleaf templates. In practice, users end up having to skip minification entirely for any file containing Thymeleaf-sensitive syntax, which pretty much defeats the purpose of using minify-html in Thymeleaf-based projects.
Syntax That Needs to Be Preserved
One of Thymeleaf's core design goals is Natural Templates — templates that can be opened directly in a browser as static prototypes, while still being processed correctly by Thymeleaf on the server. This relies on several special syntax forms that must survive minification intact:
-
JavaScript / CSS inline expressions (inside blocks with
th:inline="javascript"orth:inline="css"):/*[[ ... ]]*/— escaped output/*[( ... )]*/— unescaped output/*[# th:each="..."].../*[/]*/— inline blocks, where/*[# ...]*/is the opening marker and/*[/]*/is the closing marker
-
Advanced inlining features (also inside
th:inlineblocks):/*[+ ... +]*/— inlined code (only active when processed by Thymeleaf)/*[- ... -]*/— inlined code removal (only visible in static prototypes)
-
Prototype-only comment blocks (in regular HTML):
<!--/*/ ... /*/-->— hidden as an HTML comment when opened statically, but treated as normal markup by Thymeleaf at runtime
Suggested Support
It would be great if minify-html could add a Thymeleaf-aware preservation mode, for example via:
- a dedicated config option like
preserve_thymeleaf_template_syntax - or a more generic API for registering custom delimiter pairs / preservation markers
A generic custom-delimiter mechanism would also work well if full Thymeleaf support is out of scope.
Why This Matters
Thymeleaf is widely used in the Java ecosystem, especially in Spring applications. Better preservation support would make minify-html significantly more practical for server-rendered Java templates.
Thanks!