Class: HamlRenderer::HamlHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/gitstats/renderer/haml.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(templatedir, stats, verbose) ⇒ HamlHelper

Returns a new instance of HamlHelper.



5
6
7
8
9
10
11
12
13
14
# File 'lib/gitstats/renderer/haml.rb', line 5

def initialize(templatedir, stats, verbose)
  @templatedir = templatedir
  @stats = stats
  @verbose = verbose
  @layout = nil

  Dir.glob(File.join(templatedir, 'helpers', '*.rb')).sort.each do |file|
    eval(IO::readlines(file).join(''))
  end
end

Instance Attribute Details

#statsObject (readonly)

Returns the value of attribute stats.



3
4
5
# File 'lib/gitstats/renderer/haml.rb', line 3

def stats
  @stats
end

Instance Method Details

#get_layoutObject



29
30
31
# File 'lib/gitstats/renderer/haml.rb', line 29

def get_layout
  @layout
end

#layout(name) ⇒ Object



25
26
27
# File 'lib/gitstats/renderer/haml.rb', line 25

def layout(name)
  @layout = name.to_s
end

#partial(name, hash = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/gitstats/renderer/haml.rb', line 16

def partial(name, hash = {})
  name = name.to_s
  puts "rendering partial '#{name}' ..." if @verbose
  hash = hash.to_h unless hash.is_a? Hash
  lines = IO::readlines(File.join(@templatedir, 'partials', "#{name}.haml")).join('')
  engine = Haml::Engine.new(lines)
  engine.render(self, hash)
end