Created
December 20, 2010 15:39
-
-
Save fumokmm/748526 to your computer and use it in GitHub Desktop.
This file contains 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
// Stringを拡張してバインド変数のマップを渡してパースできるようにする | |
String.metaClass.parse = { Map binding = [:] -> | |
new groovy.text.SimpleTemplateEngine() | |
.createTemplate(new StringReader(delegate)) | |
.make(binding).toString() | |
} | |
// エルシャダイ風にテスト | |
def result = ''' | |
${user1}「${serif1}」 | |
<%= user2 %>「<%= serif2 %>」 | |
'''.parse( | |
user1: 'ルシフェル', serif1: 'そんな装備で大丈夫か?', | |
user2: 'イーノック', serif2: '大丈夫だ、問題ない' | |
) | |
assert ''' | |
ルシフェル「そんな装備で大丈夫か?」 | |
イーノック「大丈夫だ、問題ない」 | |
''' == result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment