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) ⇒ HamlHelper
constructor
A new instance of HamlHelper.
- #layout(name) ⇒ Object
- #partial(name, hash = {}) ⇒ Object
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
#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
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 |