Class: Curly::TemplateHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/curly/template_handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cache_if_key_is_not_nil(context, presenter) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/curly/template_handler.rb', line 30

def cache_if_key_is_not_nil(context, presenter)
  if key = presenter.cache_key
    if presenter.class.respond_to?(:cache_key)
      presenter_key = presenter.class.cache_key
    else
      presenter_key = nil
    end

    cache_options = presenter.cache_options || {}
    cache_options[:expires_in] ||= presenter.cache_duration

    context.cache([key, presenter_key].compact, cache_options) do
      yield
    end
  else
    yield
  end
end

Instance Method Details

#call(template, source) ⇒ Object



17
18
19
20
21
# File 'lib/curly/template_handler.rb', line 17

def call(template)
  instrument(template) do
    compile_for_actionview5(template)
  end
end