Skip to content

Instantly share code, notes, and snippets.

@romulostorel
Created December 13, 2013 20:07
Show Gist options
  • Save romulostorel/7950506 to your computer and use it in GitHub Desktop.
Save romulostorel/7950506 to your computer and use it in GitHub Desktop.
require 'erb'
require 'ostruct'
namespace = OpenStruct.new(name: 'Teste', last: 'Testador')
template = 'Name: <%= name %> <%= last %>'
puts ERB.new(template).result(namespace.instance_eval { binding })
#=> Name: Teste Testador
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment