Class: Cutaneous::CachedFileLoader
- Inherits:
-
FileLoader
- Object
- FileLoader
- Cutaneous::CachedFileLoader
- Defined in:
- lib/cutaneous/loader.rb
Overview
Caches Template instances
Instance Attribute Summary
Attributes inherited from FileLoader
#format, #syntax, #template_class
Instance Method Summary collapse
-
#initialize(template_roots, format, extension = Cutaneous.extension) ⇒ CachedFileLoader
constructor
A new instance of CachedFileLoader.
- #template(template) ⇒ Object
- #template_cache ⇒ Object
- #write_compiled_scripts=(flag) ⇒ Object
Methods inherited from FileLoader
#convert, #exists?, #filename, #lexer, #location, #open_template, #path, #render
Constructor Details
#initialize(template_roots, format, extension = Cutaneous.extension) ⇒ CachedFileLoader
Returns a new instance of CachedFileLoader.
79 80 81 82 |
# File 'lib/cutaneous/loader.rb', line 79 def initialize(template_roots, format, extension = Cutaneous.extension) super @template_class = CachedTemplate end |
Instance Method Details
#template(template) ⇒ Object
96 97 98 99 |
# File 'lib/cutaneous/loader.rb', line 96 def template(template) return template_cache[template] if template_cache.key?(template) template_cache[template] = super end |
#template_cache ⇒ Object
84 85 86 |
# File 'lib/cutaneous/loader.rb', line 84 def template_cache @template_cache ||= {} end |
#write_compiled_scripts=(flag) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/cutaneous/loader.rb', line 88 def write_compiled_scripts=(flag) if flag @template_class = CachedTemplate else @template_class = Template end end |