Last active
August 29, 2015 14:07
-
-
Save nori3tsu/64f8d67acebd7fa86a65 to your computer and use it in GitHub Desktop.
Mustacheを1ファイルで実装する例
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
require 'mustache' | |
str = <<-EOT | |
a | |
b | |
c | |
EOT | |
lines = [] | |
str.each_line do |line| | |
lines << {:line => line.chomp} | |
end | |
template = DATA.read | |
puts Mustache.render(template, :lines => lines) | |
__END__ | |
{{#lines}} | |
{{line}} !! | |
{{/lines}} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment