[Javascript] Does js have a HEREDOC like statement?

tedd tedd at sperling.com
Sat Jul 14 14:24:37 CDT 2007


Hi gang:

Ah, I found it,

Just add an escape \ at the end of each line and that's it, like so:

var message = "<h1>Hi there</h1>\
<p>\
what's happening?\
</p>";

We'll now return to regular programming.

Cheers,

tedd

---
At 2:58 PM -0400 7/14/07, tedd wrote:
>Hi gang:
>
>The subject line says it all, does javascript have a statement 
>similar to php's HEREDOC?
>
>I'm trying to create a variable where returns, white spaces, and 
>linefeeds don't matter, like this:
>
>var message = "<h1>Hi there</h1>
><p>
>what's happening?
></p>";
>
>However, that doesn't work for what I want -- so I figured that I 
>would ask this most imaginative group as to what they do.
>
>However, I did find this:
>
><script>
>
>function GetMultiLine(sStr)
>{
>var s = sStr;
>
>s = s.replace(/function/, '');
>s = s.replace(/\(/, '');
>s = s.replace(/\)/, '');
>s = s.replace(/\{/, '');
>s = s.replace(/\}/, '', -1);
>s = s.replace(/\//, '');
>s = s.replace(/\*/, '');
>s = s.replace(/\//, '', -1);
>s = s.replace(/\*/, '', -1);
>
>return s;
>}
>
>var f = function() {
>/*
>the
>quick
>brown
>fox
>jumps
>over
>the lazy dog
>*/
>};
>
>alert(GetMultiLine(new String(f)));
>
></script>
>
>But, that's a lot of work -- does anyone have a simpler method?
>
>Cheers,
>
>tedd
>
>--
>-------
>http://sperling.com  http://ancientstones.com  http://earthstones.com
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript


-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the Javascript mailing list