Class: Midwife::Helpers

Inherits:
Object
  • Object
show all
Defined in:
lib/midwife/helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(current) ⇒ Helpers

Returns a new instance of Helpers.



3
4
5
# File 'lib/midwife/helpers.rb', line 3

def initialize(current)
  @current = current
end

Instance Method Details

#render(partial) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/midwife/helpers.rb', line 7

def render(partial)
  partial_file = "#{@current}/_#{partial}.haml"
  template = File.read(partial_file)
  output = Haml::Engine.new(template).render(Helpers.new(@current))
  return output
rescue Exception => e
  puts "haml: failed to convert #{partial_file}."
  puts e.message
  puts e.backtrace.first
end