Class: MVCLI::ERB::Template
- Inherits:
-
Object
- Object
- MVCLI::ERB::Template
- Defined in:
- lib/mvcli/erb.rb
Instance Method Summary collapse
- #call(context, output) ⇒ Object
-
#initialize(code, enc, filename) ⇒ Template
constructor
A new instance of Template.
- #to_proc ⇒ Object
Constructor Details
#initialize(code, enc, filename) ⇒ Template
Returns a new instance of Template.
19 20 21 |
# File 'lib/mvcli/erb.rb', line 19 def initialize(code, enc, filename) @code, @enc, @filename = code, enc, filename end |
Instance Method Details
#call(context, output) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/mvcli/erb.rb', line 23 def call(context, output) binding = context.instance_eval do @_erbout = output Kernel.binding end eval @code, binding, @filename, 1 ensure context.remove_instance_variable(:@_erbout) end |
#to_proc ⇒ Object
33 34 35 36 37 |
# File 'lib/mvcli/erb.rb', line 33 def to_proc proc do |context, output| call context, output end end |