Class: Murdoc::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/murdoc/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_or_filename) ⇒ Formatter

Returns a new instance of Formatter.



7
8
9
10
11
12
13
# File 'lib/murdoc/formatter.rb', line 7

def initialize(template_or_filename)
  if File.exists?(template_or_filename)
    @template = File.read(template_or_filename)
  else
    @template = template_or_filename
  end
end

Instance Attribute Details

#templateObject

Returns the value of attribute template.



5
6
7
# File 'lib/murdoc/formatter.rb', line 5

def template
  @template
end

Instance Method Details

#render(locals = {}) ⇒ Object



15
16
17
# File 'lib/murdoc/formatter.rb', line 15

def render(locals = {})
  ::Haml::Engine.new(template).render(self, locals)
end