Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorah/2702141 to your computer and use it in GitHub Desktop.
Save sorah/2702141 to your computer and use it in GitHub Desktop.
口からテンプレートがどんどん出てくる
# 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