Skip to content

Instantly share code, notes, and snippets.

@joshuabaker
Created September 14, 2011 22:15
Show Gist options
  • Save joshuabaker/1217961 to your computer and use it in GitHub Desktop.
Save joshuabaker/1217961 to your computer and use it in GitHub Desktop.
hereDoc hack for javascript
function hereDoc(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
}
// usage
var tennysonQuote = hereDoc(function() {/*!
Theirs not to make reply,
Theirs not to reason why,
Theirs but to do and die
*/});
// source: http://stackoverflow.com/questions/805107/multiline-strings-in-javascript/5571069#5571069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment