4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/helpers/redmine_extensions/rendering_helper.rb', line 4
def render_with_fallback(*attrs)
raise 'Missing an options argument' unless attrs.last.is_a?(Hash)
options = attrs.last
raise 'Missing an fallback prefixes' unless options[:prefixes]
partial = options[:partial] || attrs.first
prefixes = options.delete(:prefixes)
prefixes = prefixes.model if prefixes.is_a?(BasePresenter)
prefixes = prefixes.hiearchy.map{|klass| klass.underscore.pluralize } if prefixes.is_a?(ActiveRecord::Base)
prefixes.each do |prefix|
if lookup_context.template_exists?(partial, prefix, true)
partial.prepend("#{prefix}/")
return render(*attrs)
end
end
partial.prepend("#{prefixes.last}/")
render(*attrs)
end
|