Created
May 15, 2012 14:23
-
-
Save sorah/2702141 to your computer and use it in GitHub Desktop.
口からテンプレートがどんどん出てくる
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
# coding:utf-8 | |
def render(template, variables = {}) | |
template.gsub(/✖╹ *(.+?) *╹✖/) do | |
$1.split('.').inject(variables) do |hash, key| | |
hash[key.to_sym] or break nil | |
end | |
end | |
end | |
puts render( | |
'✖╹ yunotti.mouth ╹✖', | |
yunotti: { mouth: "口からテンプレートがどんどん出てくる" } | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment