Archive for the ‘javascript’ Category

Multi-line strings in Javascript

2005-10-30

For reference in case I lose it later. Thanks to E4X, we can now have multi-line strings similar to HEREDOC syntax (although quite a bit more verbose):

  var string = (<r><![CDATA[

     The text string goes here.  Since this is a XML CDATA section,
     stuff like <> work fine too, even if definitely invalid XML.

  ]]></r>).toString();

This syntax works fine on Greasemonkey too (trunk, 2005-10-ish, GM 0.6.3). Should be useful, especially in combination with stuff like the add CSS “pattern”…

I can’t believe how much pain it is to try to get raw text in here… This is just a bit silly. Basically had to go turn off the WYSIWYG editor cocmpletely. I guess I should try doing things in an external editor instead…

Advertisements