Class: Malt::Malted

Inherits:
Object show all
Defined in:
lib/malt/tilted.rb

Overview

Base class for the Tilt-like template classes.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, options = {}) ⇒ Malted

Returns a new instance of Malted.



27
28
29
30
# File 'lib/malt/tilted.rb', line 27

def initialize(file, options={})
  @file    = file
  @options = options || {}
end

Class Method Details

.engine_indexObject



8
9
10
# File 'lib/malt/tilted.rb', line 8

def self.engine_index
  @@engine_index ||= {}
end

.malt_engine(engine_class = nil) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/malt/tilted.rb', line 13

def self.malt_engine(engine_class=nil)
  if engine_class
    @malt_engine = engine_class
    engine_index[@malt_engine] = self
  end
  @malt_engine
end

Instance Method Details

#malt_engineObject



22
23
24
# File 'lib/malt/tilted.rb', line 22

def malt_engine
  self.class.malt_engine.new(@options)
end

#render(*data, &yields) ⇒ Object



33
34
35
36
# File 'lib/malt/tilted.rb', line 33

def render(*data, &yields)
  text = File.read(@file)
  malt_engine.render(:text=>text, :file=>@file, :data=>data, &yields)
end