Class: Nova::Engine::ERB

Inherits:
Nova::Engine show all
Defined in:
lib/cocoanova/engines/erb.rb

Constant Summary

Constants inherited from Nova::Engine

Registry

Instance Method Summary collapse

Methods inherited from Nova::Engine

[], extension, require_all, supported_extensions

Instance Method Details

#render(_template, _data, _filename) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cocoanova/engines/erb.rb', line 8

def render(_template, _data, _filename)
    clazz = ::ERB.new(_template).def_class
    clazz.class_eval do
        include Nova::Helper

        def initialize(data, filename)
            @data = data
            @filename = filename
        end

        def filename
            @filename
        end

        def data
            @data
        end
    end
    clazz.new(OpenStruct.new(_data), _filename).result
end