How can I use yield for template inheritance in erb? I want to use erb in a plain ruby CGI script and want to use a base template and subtemplate like it Rails wit
def a ERB.new('<%= yield %>').result(binding) end a{123} #=> "123"
It's important that the call to Kernel#binding be inside a method, that way the context includes the block (ERB#result won't take a block).
Kernel#binding
ERB#result