yegor256
yegor256

Reputation: 105133

How can I remove HTML comments in my Facelets?

I would like to remove all HTML comments from my facelets before delivering to end users. Does any standard approach exist?

Upvotes: 29

Views: 6137

Answers (2)

BalusC
BalusC

Reputation: 1109252

There are actually two ways:

  1. To remove all comments, add this to web.xml:

     <context-param>
         <param-name>jakarta.faces.FACELETS_SKIP_COMMENTS</param-name>
         <param-value>true</param-value>
     </context-param>
    

    or when you're still on JSF 3.x/2.x:

     <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.x 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>
    
  2. To remove specific comments only, use <ui:remove>.

     <ui:remove><!-- This is a HTML comment. --></ui:remove>
    

Upvotes: 51

madx
madx

Reputation: 7203

With jakarta, to remove all comments before sending pages to the clients, add this to your web.xml:

<context-param>
    <param-name>jakarta.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
</context-param>

Upvotes: 1

Related Questions