Created
February 23, 2014 03:06
-
-
Save tuchida/9166234 to your computer and use it in GitHub Desktop.
heredoc macro
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
macro <<EOS { | |
case { $_ } => { | |
var comments = #{$_}[0].token.leadingComments; | |
var text = ''; | |
if (comments) { | |
text = comments.map(function(c) { | |
return c.type === 'Block' ? c.value.replace(/^(\r\n|\n|\r)/, '').replace(/(\r\n|\n|\r)$/, '') : c.value; | |
}).join('\r\n'); | |
} | |
return [makeValue(text, #{here})]; | |
} | |
} | |
console.log(/* | |
abcdefg | |
hijklmn | |
あいうえお | |
*/<<EOS); | |
console.log(<<EOS); | |
console.log( | |
//abcdefg | |
//hijklmn | |
//あいうえお | |
<<EOS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment