class Object
Public Instance Methods
active_template()
click to toggle source
# File lib/render_parent/rails/on_load_action_controller.rb, line 8 def active_template @active_template_stack.last end
active_template_stack()
click to toggle source
# File lib/render_parent/rails/on_load_action_controller.rb, line 4 def active_template_stack @active_template_stack ||= [] end
excluded(template) { || ... }
click to toggle source
# File lib/render_parent/rails6/on_load_action_view.rb, line 32 def excluded(template) exclusions << template yield ensure exclusions.delete template end
exclusions()
click to toggle source
# File lib/render_parent/rails2.rb, line 25 def exclusions @exclusions ||= [] end
find_all_with_exclusions(path, prefixes = [], *args)
click to toggle source
# File lib/render_parent/rails3/on_load_action_view.rb, line 35 def find_all_with_exclusions(path, prefixes = [], *args) excluded = exclusions.map(&:identifier) prefixes = [prefixes] if String === prefixes prefixes.each do |prefix| paths.each do |resolver| templates = resolver.find_all(path, prefix, *args) templates.delete_if {|t| excluded.include? t.identifier} unless templates.empty? return templates unless templates.empty? end end [] end
find_template(original_template_path, format = nil, html_fallback = true)
click to toggle source
# File lib/render_parent/rails2.rb, line 29 def find_template(original_template_path, format = nil, html_fallback = true) return original_template_path if original_template_path.respond_to?(:render) template_path = original_template_path.sub(/^\//, '') each do |load_path| if format && (template = load_path["#{template_path}.#{I18n.locale}.#{format}"]) && !exclusions.include?(template) return template # Try the default locale version if the current locale doesn't have one # (i.e. you haven't translated this view to German yet, but you have the English version on hand) elsif format && (template = load_path["#{template_path}.#{I18n.default_locale}.#{format}"]) && !exclusions.include?(template) return template elsif format && (template = load_path["#{template_path}.#{format}"]) && !exclusions.include?(template) return template elsif (template = load_path["#{template_path}.#{I18n.locale}"]) && !exclusions.include?(template) return template elsif (template = load_path["#{template_path}.#{I18n.default_locale}"]) && !exclusions.include?(template) return template elsif (template = load_path[template_path]) && !exclusions.include?(template) return template # Try to find html version if the format is javascript elsif format == :js && html_fallback && (template = load_path["#{template_path}.#{I18n.locale}.html"]) && !exclusions.include?(template) return template elsif format == :js && html_fallback && (template = load_path["#{template_path}.#{I18n.default_locale}.html"]) && !exclusions.include?(template) return template elsif format == :js && html_fallback && (template = load_path["#{template_path}.html"]) && !exclusions.include?(template) return template end end return ActionView::Template.new(original_template_path) if File.file?(original_template_path) raise ActionView::MissingTemplate.new(self, original_template_path, format) end
initialize_with_exclusions(view_paths, details = {}, prefixes = [])
click to toggle source
# File lib/render_parent/rails6/on_load_action_view.rb, line 61 def initialize_with_exclusions(view_paths, details = {}, prefixes = []) initialize_without_exclusions(view_paths, details, prefixes) @view_paths.exclusions = view_paths.exclusions if view_paths.is_a?(ActionView::PathSet) end
render_parent_template(local_assigns = {}, &block)
click to toggle source
# File lib/render_parent/rails2.rb, line 4 def render_parent_template(local_assigns = {}, &block) view_paths.exclusions << template result = render(:file => template.to_s, :locals => local_assigns, &block) view_paths.exclusions.delete template result end
render_with_active_template(view, locals, buffer=nil, &block)
click to toggle source
# File lib/render_parent/rails3/on_load_action_view.rb, line 52 def render_with_active_template(view, locals, buffer=nil, &block) template_stack = view.controller.respond_to?(:active_template_stack) && view.controller.active_template_stack template_stack.push(self) if template_stack result = render_without_active_template(view, locals, buffer, &block) template_stack.pop if template_stack result end
render_with_parent(options = {}, local_assigns = {}, &block)
click to toggle source
# File lib/render_parent/rails2.rb, line 11 def render_with_parent(options = {}, local_assigns = {}, &block) if options == :parent render_parent_template(local_assigns, &block) else render_without_parent(options, local_assigns, &block) end end