Class: Curlybars::TemplateHandler
- Inherits:
-
Object
- Object
- Curlybars::TemplateHandler
- Defined in:
- lib/curlybars/template_handler.rb
Class Method Summary collapse
- .cache_if_key_is_not_nil(context, presenter) ⇒ Object
-
.call(template, source) ⇒ Object
Handles a Curlybars template, compiling it to Ruby code.
Class Method Details
.cache_if_key_is_not_nil(context, presenter) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/curlybars/template_handler.rb', line 22 def cache_if_key_is_not_nil(context, presenter) key = presenter.cache_key if key.present? presenter_key = if presenter.class.respond_to?(:cache_key) presenter.class.cache_key end = presenter. || {} [:expires_in] ||= presenter.cache_duration # Curlybars doesn't allow Rails to handle the template digest. # So, we disable it. [:skip_digest] = true context.cache([key, presenter_key].compact, ) do yield end else yield end end |
.call(template, source) ⇒ Object
Handles a Curlybars template, compiling it to Ruby code. The code will be evaluated in the context of an ActionView::Base instance, having access to a number of variables.
template - The ActionView::Template template that should be compiled.
Returns a String containing the Ruby code representing the template.
16 17 18 19 20 |
# File 'lib/curlybars/template_handler.rb', line 16 def call(template, source) instrument(template) do compile(template, source) end end |