I'm using Java Facelets and jQuery, however the expression
$('...')
in jQuery conflicts with EL expression, how do I escape the jQuery's one?
I'd like to escape a large chunk of Javascript, too.
ANSWERED
To convert the existing JSP to Facelets xhtml, it's convenient to just wrap the existing javascript by <![CDATA[ ... ]]>
. However, the output scripts for <script>
are wrapped by <!-- -->
comment, which conflicts with CDATA section:
<script><![CDATA[ scripts... ]]></script>
=> <script><!-- <![CDATA[ scripts... ]]> --></script>
To resolve this problem, you should also comment out the CDATA:
<script>/* <![CDATA[ */ scripts... /* ]]> */</script>
=> <script><!-- /* <![CDATA[ */ scripts... /* ]]> */--></script>
See also When is a CDATA section necessary within a script tag?.
$
which should be represented as&
. Apart from the uglyCDATA
workaround, the best solution is to put JS code in its own.js
file. After all, the question title and body does not describe the real problem and is therefore misleading. – Penates