Class: Racket::Utils::Views::TemplateCache

Inherits:
Object
  • Object
show all
Defined in:
lib/racket/utils/views.rb

Overview

Cache for storing templates

Instance Method Summary collapse

Constructor Details

#initializeTemplateCache

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.

Parameters:

Returns:

  • (String|Proc|nil)


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