Module: Plezi::Base::RenderERB

Extended by:
HasStore
Defined in:
lib/plezi/render/erb.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasStore

get, store

Class Method Details

.call(filename, context, &block) ⇒ Object



9
10
11
12
13
14
# File 'lib/plezi/render/erb.rb', line 9

def call(filename, context, &block)
   return unless defined? ::ERB
   return unless File.exist?(filename)
   engine = load_engine(filename)
   engine.result(context, &block)
end

Instance Method Details

#load_engine(filename) ⇒ Object



16
17
18
19
20
# File 'lib/plezi/render/erb.rb', line 16

def load_engine(filename)
   engine = self[filename]
   return engine if engine
   self[filename] = ::ERB.new(::Plezi.try_utf8!(IO.binread(filename)))
end