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!
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.
The reason I was looking for it was a need to pass multi-line html text (keeping nice html indents and without splitting it to js strings) as an argument to a template engine.
Finally for my problem I just created a template engine with a heredoc block - so if you anybody is looking for heredoc just for more convenient way to write his templates - the https://github.com/AlexLibs/hot can be used (the module is registered on npm).