Created
September 14, 2011 22:15
-
-
Save joshuabaker/1217961 to your computer and use it in GitHub Desktop.
hereDoc hack for javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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