Creating multiline strings in JavaScript -


i have following code in ruby. want convert code javascript. what's equivalent code in js?

text = <<"here" multiline string here 

update:

ecmascript 6 (es6) introduces new type of literal, namely template literals. have many features, variable interpolation among others, importantly question, can multiline.

a template literal delimited backticks:

var html = `   <div>     <span>some html here</span>   </div> `; 

(note: i'm not advocating use html in strings)

browser support ok, can use transpilers more compatible.


original es5 answer:

javascript doesn't have here-document syntax. can escape literal newline, however, comes close:

"foo \ bar" 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -