Class: HamlRenderer::HamlHelper
- Inherits:
-
Object
- Object
- HamlRenderer::HamlHelper
- Defined in:
- lib/gitstats/renderer/haml.rb
Instance Attribute Summary collapse
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
- #get_layout ⇒ Object
-
#initialize(templatedir, stats, verbose, engineConfig) ⇒ HamlHelper
constructor
A new instance of HamlHelper.
- #layout(name) ⇒ Object
- #partial(name, hash = {}) ⇒ Object
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
#stats ⇒ Object (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_layout ⇒ Object
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 |