Skip to content

Instantly share code, notes, and snippets.

@brooklynDev
Last active August 29, 2015 14:06
Show Gist options
  • Save brooklynDev/d7bc8031f2c50176bc9c to your computer and use it in GitHub Desktop.
Save brooklynDev/d7bc8031f2c50176bc9c to your computer and use it in GitHub Desktop.
ERB compile one liner
require 'erb'
require 'ostruct'
class << ERB
def compile(template, locals)
renderer = ERB.new(template)
struct = OpenStruct.new(locals)
class << struct
def get_binding
binding()
end
end
renderer.result(struct.get_binding)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment