Module: Nokogiri::Cache
- Defined in:
- lib/nokogiri/cache.rb,
lib/nokogiri/cache/version.rb
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Method Summary collapse
-
#cache(name, options = nil, &block) ⇒ Object
Allow nokogiri templates to do fragment caching We can’t just use Rails’ built in cache helper because the document is not built as we go along so the output buffer has no data Instead, we can override caching to be able to put XML fragments into the cache and pull them out to be inserted into a document later NOTE: This code mostly mirrors action_view/helpers/cache_helper.rb.
Instance Method Details
#cache(name, options = nil, &block) ⇒ Object
Allow nokogiri templates to do fragment caching We can’t just use Rails’ built in cache helper because the document is not built as we go along so the output buffer has no data Instead, we can override caching to be able to put XML fragments into the cache and pull them out to be inserted into a document later NOTE: This code mostly mirrors action_view/helpers/cache_helper.rb
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nokogiri/cache.rb', line 12 def cache(name, = nil, &block) @context = eval('self', block.binding) controller = @context.controller if controller.perform_caching get_fragment(controller, name, , &block) else yield self end end |