Sorry, can't seem to find the syntax. Trying to look for the equivalent of
text = <<"HERE" This Is A Multiline String HERE
[from Ruby] in Javscript
Sorry, can't seem to find the syntax. Trying to look for the equivalent of
text = <<"HERE" This Is A Multiline String HERE
[from Ruby] in Javscript
You can do this
var string = 'This is ' +
'multiline' + 
'string';
You can also do it like this. According to kooiinc, it doesn't work in IE, so it's quite useless...
var myString = ""+<r><![CDATA[
      <div id="example">
          <p>Awesome multiline string!</p>
      </div>
  ]]></r>;
Javascript doesn't have a here-document syntax. You can escape the literal newline, however, which comes close:
"foo \
bar"
the pattern text = <<"HERE" This Is A Multiline String HERE is not available in js (I remember using it much in my good old Perl days).
To keep oversight with complex or long multiline strings I sometimes use an array pattern:
var myString = 
   ['<div id="someId">',
    'some content<br />',
    '<a href="#someRef">someRefTxt</a>',
    '</div>'
   ].join('\n');
or the pattern anonymouos already showed (escape newline), which can be an ugly block in your code:
    var myString = 
       '<div id="someId"> \
some content<br /> \
<a href="#someRef">someRefTxt</a> \
</div>';
i tried all above items ...but did not work in IE... anybody able to work multiline string with java script in IE (IE6/7)