How to add source code comments in Thymeleaf templates that don’t get included in generated HTML?

Version 2.1 is released so now you can upgrade your libraries and use comments in your code. With this version developers are able to use parser-level comment blocks:

<!--/* This code will be removed at thymeleaf parsing time! */-->

and prototype-only comment blocks:

<span>hello!</span>
<!--/*/
    <div th:text="${...}">

</div>
/*/-->
<span>goodbye!</span>

Detailed explanation can be found in the official documentation here: http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#comments-and-blocks

Leave a Comment