Skip to content

Instantly share code, notes, and snippets.

@yatemmma
Created December 1, 2013 08:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yatemmma/7729759 to your computer and use it in GitHub Desktop.
Save yatemmma/7729759 to your computer and use it in GitHub Desktop.
javascriptでヒアドキュメント風
Function.prototype.heredoc = function() {
return this.toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1].replace(/^\n/, "");
};
var doc = (function() {/*
hoge hoge
fuga fuga
piyo piyo
*/}).heredoc();
alert(doc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment