Skip to content

Instantly share code, notes, and snippets.

@genta
Created September 1, 2015 07:55
Show Gist options
  • Select an option

  • Save genta/ff0e790830d3ec5b3ffc to your computer and use it in GitHub Desktop.

Select an option

Save genta/ff0e790830d3ec5b3ffc to your computer and use it in GitHub Desktop.
Simple wrapper for ERB
require 'erb'
class ERB
def self.str(template, binding = TOPLEVEL_BINDING)
self.new(template, nil, '%<>-').result(binding)
end
end
if __FILE__ == $PROGRAM_NAME
puts ERB.str(<<-_EOD_)
Hello, erbstr.
%
%
----
% dice_2d6 = rand(6) + rand(6)
2D6: <%= dice_2d6 -%>
% if dice_2d6.even?
(even)
% else
(odd)
% end
----
%
%
% 10.times do |i|
Loop count: <%= i %>.
% end
_EOD_
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment