Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

heredoc on nodejs

Trying to use the Heredoc Method described here: http://www.developfortheweb.com/2009/03/multi-line-strings-in-javascript/

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();

I can't make it work on node.js. I tested it on client side - it works on Firefox, but Chrome.

How should I use this method on node.js?

Thanks!

like image 702
Alexander Avatar asked Jul 23 '26 20:07

Alexander


1 Answers

Even though this blog posts tells you something else, JavaScript does not have heredoc strings.

So you should not use it at all - it is a dirty hack. The reason why it works in some browsers is that they allow inline XML. NodeJS probably doesn't because well, it's ugly and dirty.

like image 60
ThiefMaster Avatar answered Jul 25 '26 08:07

ThiefMaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!