Sha256: 1bd73e667720fc475fc05185b1a52fd03397f44f265d96c56a532efc8ca0fad6
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
module Mack module Distributed class ViewCache < Cachetastic::Caches::Base class << self include Mack::ViewHelpers def get(path) if configatron.mack.distributed.enable_view_cache raw = super(path) do get_raw_data(path, true) end else raw = get_raw_data(path, false) end return raw end # def get private def get_raw_data(path, cache_data = true) if File.exists?(path) raw = File.read(path) # preprocess the raw content so we can resolve css/javascript/image path arr = raw.scan(/<%=.*?%>/) arr.each do |scriptlet| if scriptlet.match(/stylesheet/) or scriptlet.match(/javascript/) or scriptlet.match(/image/) res = ERB.new(scriptlet).result(binding) raw.gsub!(scriptlet, res) end end # if arr.each end # if File.exists? set(path, raw) if cache_data raw end # get_raw_data end # class << self end # ViewCache end # Distributed end # Mack
Version data entries
4 entries across 4 versions & 1 rubygems