Created
April 27, 2017 17:55
-
-
Save richseviora/d46fe0baa02e97e5b475b43cd1647d8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView | |
class Digestor | |
class << self | |
def tree(name, finder, partial = false, seen = {}) | |
logical_name = name.gsub(%r|/_|, "/") | |
options = {} | |
options[:formats] = [finder.rendered_format] if finder.rendered_format | |
options[:formats].push(:html,:json) if finder.rendered_format == :js | |
if template = finder.disable_cache { finder.find_all(logical_name, [], partial, [], options).first } | |
finder.rendered_format ||= template.formats.first | |
if node = seen[template.identifier] # handle cycles in the tree | |
node | |
else | |
node = seen[template.identifier] = Node.create(name, logical_name, template, partial) | |
deps = DependencyTracker.find_dependencies(name, template, finder.view_paths) | |
deps.uniq { |n| n.gsub(%r|/_|, "/") }.each do |dep_file| | |
node.children << tree(dep_file, finder, true, seen) | |
end | |
node | |
end | |
else | |
logger.error " '#{name}' file doesn't exist, so no dependencies" | |
logger.error " Couldn't find template for digesting: #{name}" | |
seen[name] ||= Missing.new(name, logical_name, nil) | |
end | |
end | |
end | |
end | |
end | |
Rails.logger.warn "Review Monkey Patch #{__FILE__}, https://github.com/rails/rails/issues/28503" if DateTime.now > DateTime.new(2017,9,1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment