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


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

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


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

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