Class: Bgem::Output::Exts::ERB::Default
- Inherits:
-
Object
- Object
- Bgem::Output::Exts::ERB::Default
- Includes:
- Bgem::Output::Exts::ERB
- Defined in:
- lib/bgem.rb
Instance Attribute Summary
Attributes included from Bgem::Output::Ext::Common
#code, #dir, #file_extension, #name, #type
Instance Method Summary collapse
Methods included from Bgem::Output::Ext::Common
Instance Method Details
#to_s ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/bgem.rb', line 205 def to_s " module \#{@name}\n class Context\n def env\n binding\n end\n end\n\n def self.[] params\n env = Context.new.env\n params.each do |name, value|\n env.local_variable_set name, value\n end\n\n template = <<~TEMPLATE\n \#{@code}TEMPLATE\n\n require 'erb'\n renderer = ERB.new template\n renderer.result env\n end\n end\n S\nend\n" |