Skip to content

Instantly share code, notes, and snippets.

@secobi
Created November 22, 2013 17:17
Show Gist options
  • Select an option

  • Save secobi/7603548 to your computer and use it in GitHub Desktop.

Select an option

Save secobi/7603548 to your computer and use it in GitHub Desktop.
multiline javascript string demo
//code from http://eli.thegreenplace.net/2013/11/09/javascript-es-5-hack-for-clean-multi-line-strings/
//typical multiline string variable
var s = "\
line one\n\
line two\n\
line 'three'\n";
//"hacked" multiline string variable
var MultiString = function(f) {
return f.toString().split('\n').slice(1, -1).join('\n');
}
var ms = MultiString(function() {/**
line one
line two
line 'three'
**/});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment