Class: HamlRenderer
- Inherits:
-
Object
- Object
- HamlRenderer
- Defined in:
- lib/gitstats/renderer/haml.rb
Defined Under Namespace
Classes: HamlHelper
Instance Method Summary collapse
- #handle?(file) ⇒ Boolean
-
#initialize(templatedir, outdir, verbose) ⇒ HamlRenderer
constructor
A new instance of HamlRenderer.
- #name ⇒ Object
- #render(file, stats) ⇒ Object
Constructor Details
#initialize(templatedir, outdir, verbose) ⇒ HamlRenderer
Returns a new instance of HamlRenderer.
35 36 37 38 39 40 |
# File 'lib/gitstats/renderer/haml.rb', line 35 def initialize(templatedir, outdir, verbose) @templatedir = templatedir @outdir = outdir @verbose = verbose @engineConfig = {} end |
Instance Method Details
#handle?(file) ⇒ Boolean
46 47 48 |
# File 'lib/gitstats/renderer/haml.rb', line 46 def handle?(file) file =~ /\.haml$/ end |
#name ⇒ Object
42 43 44 |
# File 'lib/gitstats/renderer/haml.rb', line 42 def name 'haml' end |
#render(file, stats) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gitstats/renderer/haml.rb', line 50 def render(file, stats) ifile = File.join(@templatedir, file) ofile = File.join(@outdir, File.basename(file, '.haml') + '.html') lines = IO::readlines(ifile).join('') helper = HamlHelper.new(@templatedir, stats, @verbose, @engineConfig) engine = Haml::Engine.new(lines, @engineConfig) lines = engine.render(helper) if !helper.get_layout.nil? puts "rendering layout '#{helper.get_layout}' ..." if @verbose layout = IO::readlines(File.join(@templatedir, 'layouts', helper.get_layout + '.haml')).join('') engine = Haml::Engine.new(layout, @engineConfig) lines = engine.render(helper, :content => lines) end File.new(ofile, 'w').write(lines) end |