Created
September 1, 2015 07:55
-
-
Save genta/ff0e790830d3ec5b3ffc to your computer and use it in GitHub Desktop.
Simple wrapper for ERB
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
| 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