[Javascript] Does js have a HEREDOC like statement?
tedd
tedd at sperling.com
Sat Jul 14 13:58:58 CDT 2007
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
More information about the Javascript
mailing list