<script type="text/javascript"> - generate CDATA as well ?

The correct way of writing JS ]]> blocks is following:

        //
        
]]>


How about IDEA will generate those CDATA blocks as well when completing the code after ]]> if type chosen is "text/javascript" ?

0

All right, for the personal use - I'll just use Live Templates .. :)

0


There's a "Surround with...CDATA section" template.


0

Ah, never used this one. Thanks !

But still - if IDEA clearly sees the user is going to write a JS script block - it may still add a CDATA section by itself, enforcing a correct writing style. Otherwise people may not even remember to provide one.

0

For what it's worth I prefer a style without any comments and/or CDATA sections
myself.


0
Avatar
Permanently deleted user

Hello Taras,

For what it's worth I prefer a style without any comments and/or CDATA
sections myself.


The trick about the comments is to make XHTML work in both Internet Explorer and FireFox, etc.: IE
doesn't understand XHTML and implicitly assumes ]]> to be CDATA, so the section start/end
appears to be commented out. FF however needs the CDATA for things like "i < j" in JS.

Browser Hell ;)

Sascha

0

In our JSF application we use RichFaces and Ajax4jsf. Ajax4jsf needs HTMl response to be a legal XHTML page so it requires developers to put it's own Servlet Filter that parses the output and wraps all ]]> content in CDATA if it doesn't appear there already.

0

FF however needs the CDATA for things like "i < j" in JS.


Right, forgot to mention it. IDEA needs it as well - otherwise it complains about &, inside

0

请先登录再写评论。