Created
December 13, 2014 08:55
-
-
Save martin-brennan/95d2874e90f8662a50cb to your computer and use it in GitHub Desktop.
hasherb.rb
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' | |
require 'ostruct' | |
opts = OpenStruct.new({ | |
first_name: "Martin", | |
last_name: "Brennan" | |
}) | |
# load the erb template. 'Hello <%= first_name %> <%= last_name %>.' | |
template = File.read('template.erb') | |
# render the template | |
puts ERB.new(template).result(opts.instance_eval {binding}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment