I am using full stack Thymeleaf (spring mvc, security, layout dialect, webflow) in a mid-size web application.
Ok..now that we put so much of code in the html templates
With Thymeleaf 3.0, the currently working version was
<!--/*-->
this comment will be removed by thymeleaf on the template processing
<!--*/-->
Other answers, for earlier thymeleaf versions, did not work by me. The current thymeleaf documentation is here.
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
Prior to version 2.1 you can do this
<th:block th:if="${false}"><!-- ignore me --></th:block>
Its very ugly (the th:block
needing a false th:if
) but works.
It's not possible in current stable version of Thymeleaf. It's planned for version 2.1 as mentioned in Thymeleaf Issue 10
As mentioned Rafal Borowiec to comment block of HTML code you should use
<!--/*
something to comment*/-->
construction (see documentation).
Also it is possible to comment/remove your javascript code using thymeleaf with
/*[-
something to comment -]*/
construction (see documentation). So you can annotate your js code without leaking any information
/*[-
*
* Some information about function.
*
* -]*/
function someFunction() {
console.log('Hello world');
}