Sha256: e243e0251af44337b125845188880be9ee3d56265f53dbc0271eb4c9e8fc4dfe
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
module Qor module CacheHelper def qor_cache_includes(filename, &blk) env = respond_to?(:request) && request.respond_to?(:env) ? request.env : {} path = URI.parse(filename).path rescue filename node = Qor::Cache::Configuration.deep_find(:cache_includes, path)[0] cache_key = node.nil? ? "" : qor_cache_key(*node.data.select {|x| x.is_a? String }, &node.block) cache_key += qor_cache_key(&blk) if block_given? key = "/qor_cache_includes/#{filename}?#{cache_key}" if env['QOR_CACHE_SSI_ENABLED'] %Q[<!--# include virtual="#{key}" -->] elsif env['QOR_CACHE_ESI_ENABLED'] %Q[<esi:include src="#{key}"/>] else render_qor_cache_includes(path, key) end.html_safe end def render_qor_cache_includes(path, cache_key) options = Qor::Cache::Configuration.first(:cache_includes, path).try(:options) || {} format = params["format"] || "html" rescue "html" file = Dir[File.join(Rails.root, "app/views/qor_cache_includes", "#{path}.#{format}*")][0] if options.delete(:no_cache) == true Erubis::Eruby.new(File.read(file)).result(binding) else Rails.cache.fetch(cache_key, options) { Erubis::Eruby.new(File.read(file)).result(binding) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
qor_cache-0.0.3 | app/helpers/qor/cache_helper.rb |