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.



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

def initialize(name, layout = nil)
  @name = name
  @layout = layout
  @template = Tilt.new(GitStats.root.join("templates/#{@name}.haml"))
end

Instance Method Details

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



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

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