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, engineConfig) ⇒ HamlHelper

Returns a new instance of HamlHelper.



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

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

  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



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

def get_layout
  @layout
end

#layout(name) ⇒ Object



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

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

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



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

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, @engineConfig)
  engine.render(self, hash)
end