I would like to remove all HTML comments from my facelets before delivering to end users. Does any standard approach exist?
Asked
Active
Viewed 5,740 times
1 Answers
50
There are actually two ways:
To remove ALL comments, add this to
web.xml
:<context-param> <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param>
or when you're still on JSF 1.2 which doesn't use Facelets as default view technology yet:
<context-param> <param-name>facelets.SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param>
To remove specific comments only, use
<ui:remove>
.<ui:remove><!-- This is a HTML comment. --></ui:remove>
-
5Didn't know that, and i've been working with JSF/Facelets for 1 year. – f1sh Aug 02 '10 at 15:26
-
@Koray: By reading docs (context param is mentioned in page 11-3 of [JSF 2 spec](http://download.oracle.com/otn-pub/jcp/jsf-2.0-fr-full-oth-JSpec/jsf-2_0-fr-spec.pdf)). – BalusC Jul 22 '16 at 18:54
-
@BalusC This is the draft, isn 't it? Is there no final version? – Koray Tugay Jul 22 '16 at 18:55
-
@Koray: no draft, "fr" is final, see also http://download.oracle.com/otndocs/jcp/jsf-2.0-fr-full-oth-JSpec – BalusC Jul 22 '16 at 18:57