<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" ?
Please sign in to leave a comment.
All right, for the personal use - I'll just use Live Templates .. :)
There's a "Surround with...CDATA section" template.
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.
For what it's worth I prefer a style without any comments and/or CDATA sections
myself.
Hello Taras,
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
But it's a requirement for providing valid XHTML pages:
http://javascript.about.com/library/blxhtml.htm
http://www.codehouse.com/javascript/tips/xhtml/
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.
Right, forgot to mention it. IDEA needs it as well - otherwise it complains about &, inside
http://www.jetbrains.net/jira/browse/IDEA-14766