Class: Jekyll::LiquidRenderer
- Inherits:
-
Object
- Object
- Jekyll::LiquidRenderer
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll/liquid_renderer.rb,
lib/jekyll/liquid_renderer/file.rb,
lib/jekyll/liquid_renderer/table.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
-
#cache ⇒ Object
A persistent cache to store and retrieve parsed templates based on the filename via ‘LiquidRenderer::File#parse`.
- #file(filename) ⇒ Object
- #increment_bytes(filename, bytes) ⇒ Object
- #increment_count(filename) ⇒ Object
- #increment_time(filename, time) ⇒ Object
-
#initialize(site) ⇒ LiquidRenderer
constructor
A new instance of LiquidRenderer.
- #reset ⇒ Object
- #stats_table(num_of_rows = 50) ⇒ Object
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
53 54 55 |
# File 'lib/jekyll/liquid_renderer.rb', line 53 def self.format_error(error, path) "#{error.} in #{path}" end |
Instance Method Details
#cache ⇒ Object
A persistent cache to store and retrieve parsed templates based on the filename via ‘LiquidRenderer::File#parse`
It is emptied when ‘self.reset` is called.
61 62 63 |
# File 'lib/jekyll/liquid_renderer.rb', line 61 def cache @cache ||= {} end |
#file(filename) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jekyll/liquid_renderer.rb', line 24 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 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_count(filename) ⇒ Object
45 46 47 |
# File 'lib/jekyll/liquid_renderer.rb', line 45 def increment_count(filename) @stats[filename][:count] += 1 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 |
#reset ⇒ Object
19 20 21 22 |
# File 'lib/jekyll/liquid_renderer.rb', line 19 def reset @stats = {} @cache = {} end |
#stats_table(num_of_rows = 50) ⇒ Object
49 50 51 |
# File 'lib/jekyll/liquid_renderer.rb', line 49 def stats_table(num_of_rows = 50) LiquidRenderer::Table.new(@stats).to_s(num_of_rows) end |