Skip to content

Instantly share code, notes, and snippets.

@martin-brennan
Created December 13, 2014 08:55
Show Gist options
  • Save martin-brennan/95d2874e90f8662a50cb to your computer and use it in GitHub Desktop.
Save martin-brennan/95d2874e90f8662a50cb to your computer and use it in GitHub Desktop.
hasherb.rb
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