Class: GitStats::StatsView::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/git_stats/stats_view/template.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, layout = nil) ⇒ Template

Returns a new instance of Template.


5
6
7
8
9
# File 'lib/git_stats/stats_view/template.rb', line 5

def initialize(name, layout=nil)
  @name = name
  @layout = layout
  @template = Tilt.new("../../../../templates/#@name.haml".absolute_path)
end

Instance Method Details

#render(data, params = {}) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/git_stats/stats_view/template.rb', line 11

def render(data, params={})
  if @layout
    @layout.render(data, :active_page => params[:active_page] || @name, :links => params[:links]) { @template.render(data, params) }
  else
    @template.render(data, params)
  end
end