fork download
  1. require "ostruct"
  2. require "erb"
  3.  
  4. $thing = "weird thing"
  5.  
  6. class Context < OpenStruct
  7. def render(template)
  8. ERB.new(template, 4).result(binding().taint())
  9. end
  10. end
  11.  
  12. context = Context.new({:symbol => "sweet symbol", "string" => "splendid string"})
  13. puts(context.render("I'm rendering a <%= symbol %> and a <%= string %>. There's also a <%= $thing %> I shouldn't be able to access."))
  14.  
Success #stdin #stdout 0.02s 7636KB
stdin
Standard input is empty
stdout
I'm rendering a sweet symbol and a splendid string. There's also a weird thing I shouldn't be able to access.