-
-
Save anonymous/babe911728e2bbf455acbd00d1446bc8 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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