Class: Racket::Utils::Views::TemplateCache
- Inherits:
-
Object
- Object
- Racket::Utils::Views::TemplateCache
- Defined in:
- lib/racket/utils/views.rb
Overview
Cache for storing templates
Instance Method Summary collapse
-
#ensure_in_cache(path, template_params) ⇒ String|Proc|nil
Returns a cached template.
-
#initialize ⇒ TemplateCache
constructor
A new instance of TemplateCache.
Constructor Details
#initialize ⇒ TemplateCache
Returns a new instance of TemplateCache.
27 28 29 |
# File 'lib/racket/utils/views.rb', line 27 def initialize @cache = {} end |
Instance Method Details
#ensure_in_cache(path, template_params) ⇒ String|Proc|nil
Returns a cached template. If the template has not been cached yet, this method will run a lookup against the provided parameters.
37 38 39 40 |
# File 'lib/racket/utils/views.rb', line 37 def ensure_in_cache(path, template_params) return @cache[path] if @cache.key?(path) @cache[path] = TemplateLocator.calculate_path(path, template_params) end |