Skip to content

Instantly share code, notes, and snippets.

/test.rb Secret

Created March 5, 2017 01:16
Show Gist options
  • Save anonymous/babe911728e2bbf455acbd00d1446bc8 to your computer and use it in GitHub Desktop.
Save anonymous/babe911728e2bbf455acbd00d1446bc8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'erb'
class Bindable
def get_binding
return binding()
end
end
def render(str, hs)
o = Bindable.new
hs.each do |k, v|
o.instance_variable_set("@#{k}".to_s, v)
end
ERB.new(str).result(o.get_binding)
end
Result = render("<%= @contents %>", {contents: "hello"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment