11

I am using JSF 2.0 and have defined property javax.faces.FACELETS_SKIP_COMMENTS to skip comments in JSF code because there is a lot of other code, deveploping comments etc. But I need to print some HTML comments into client's browser eg. for defining alternative conditioned stylesheet for other browsers.

Please is there any way how to do it? Because all my attempts failed.

Gaim
  • 6,734
  • 4
  • 38
  • 58

4 Answers4

9

This is crude but it does work (under JSF 1.2 anyway not tested in 2)

<h:outputText value="&lt;!--" escape="false" /> My comment <h:outputText value="--&gt;" escape="false" />
reevesy
  • 3,452
  • 1
  • 26
  • 23
5

Use <ui:remove> to remove comments instead of the context parameter.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Yea I know about that but it is really uncomfortable especially If I consider amount of comments which shouldn't be rendered in HTML and that I have an existing project – Gaim Nov 21 '10 at 20:42
  • Sorry, can't help that. Just open all files in a bit decent texteditor with "Find and replace in all files" facility like Ultraedit, Notepad++ and Editplus. Replace `` by `-->`. Shouldn't take more than a few minutes. – BalusC Nov 21 '10 at 20:45
  • Okey, thanks for advice. That is probably the only possible solution :-( – Gaim Nov 21 '10 at 21:39
5

Maybe you could use f:verbatim:

<f:verbatim>&lt;!--[if lt IE 7]&gt;
    Something just for lower than IE7
&lt;![endif]--&gt;</f:verbatim>
1

Based on @Juan's and @reevesy's ideas is this one:

<f:verbatim>&lt;!--
    This is a happy HTML comment :)
--&gt;</f:verbatim>

Which will render:

<!--
    This is a happy HTML comment :)
-->
Saintali
  • 4,482
  • 2
  • 29
  • 49