Module: Plezi::Base::RenderSlim

Extended by:
HasStore
Defined in:
lib/plezi/render/slim.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/slim.rb', line 9

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

Instance Method Details

#load_engine(filename) ⇒ Object



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

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