I'm using backbone.js and underscore.js templates in a JSF application with Facelets.
The issue I'm having is that double-quotes in template expressions like
<script type="text/template">
{{ if (x == "foo") }}
....
</script>
are getting escaped like "foo"
.
What's the best way to avoid this?
If I put <![CDATA[
as the first thing in my <script>
tag, then I also see the CDATA
in the template output.
If I try to put the template in an external .js file, then Eclipse complains heavily because the template is not Javascript code.
I'm thinking maybe put the template in another file with a different extension other than .js?
Try wrapping your Javascript code in f:verbatim
:
<f:verbatim>
<script type="text/template">
{{ if (x == "foo") }}
....
</script>
</f:verbatim>