Class: Jekyll::LiquidRenderer

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jekyll/liquid_renderer.rb,
lib/jekyll/liquid_renderer/file.rb

Defined Under Namespace

Classes: File, Table

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ LiquidRenderer

Returns a new instance of LiquidRenderer.



13
14
15
16
17
# File 'lib/jekyll/liquid_renderer.rb', line 13

def initialize(site)
  @site = site
  Liquid::Template.error_mode = @site.config["liquid"]["error_mode"].to_sym
  reset
end

Class Method Details

.format_error(error, path) ⇒ Object



49
50
51
# File 'lib/jekyll/liquid_renderer.rb', line 49

def self.format_error(error, path)
  "#{error.message} in #{path}"
end

Instance Method Details

#file(filename) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jekyll/liquid_renderer.rb', line 23

def file(filename)
  filename.match(filename_regex)
  filename =
    if Regexp.last_match(1) == theme_dir("")
      ::File.join(::File.basename(Regexp.last_match(1)), Regexp.last_match(2))
    else
      Regexp.last_match(2)
    end
  LiquidRenderer::File.new(self, filename).tap do
    @stats[filename] ||= new_profile_hash
    @stats[filename][:count] += 1
  end
end

#increment_bytes(filename, bytes) ⇒ Object



37
38
39
# File 'lib/jekyll/liquid_renderer.rb', line 37

def increment_bytes(filename, bytes)
  @stats[filename][:bytes] += bytes
end

#increment_time(filename, time) ⇒ Object



41
42
43
# File 'lib/jekyll/liquid_renderer.rb', line 41

def increment_time(filename, time)
  @stats[filename][:time] += time
end

#resetObject



19
20
21
# File 'lib/jekyll/liquid_renderer.rb', line 19

def reset
  @stats = {}
end

#stats_table(num_of_rows = 50) ⇒ Object



45
46
47
# File 'lib/jekyll/liquid_renderer.rb', line 45

def stats_table(num_of_rows = 50)
  LiquidRenderer::Table.new(@stats).to_s(num_of_rows)
end