Skip to content

Instantly share code, notes, and snippets.

@jeromeetienne
Last active June 10, 2019 20:59
Show Gist options
  • Save jeromeetienne/6257420 to your computer and use it in GitHub Desktop.
Save jeromeetienne/6257420 to your computer and use it in GitHub Desktop.
a snippet to have multi lines string in javascript.
var multilineString = (function(){ /*
this
is
a
multiline
string.
*/}).toString().split('\n').slice(1, -1).join('\n');
console.log(multilineString);
@henderbj
Copy link

For me it worked good. I want it to have PGN chess games into a javascript variable. For sure having html tags, javascript, or php inside the string will cause problems, at least that you add the logic to escape them. For everything rest, this is good. Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment