diff options
author | artemave <artemave@gmail.com> | 2010-09-17 20:39:14 +0000 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-12-26 22:32:15 -0800 |
commit | ddd85ef9c6a6297a8ff28816d907bbbf2eae5856 (patch) | |
tree | b2ff8ede17f042e8e007c6103b4063ce7ac75383 /actionpack/lib/action_view/lookup_context.rb | |
parent | 9bac649fa4ca6f05795e7cab8d30049aa2410cb8 (diff) | |
download | rails-ddd85ef9c6a6297a8ff28816d907bbbf2eae5856.tar.gz rails-ddd85ef9c6a6297a8ff28816d907bbbf2eae5856.tar.bz2 rails-ddd85ef9c6a6297a8ff28816d907bbbf2eae5856.zip |
#948 template_inheritance
Diffstat (limited to 'actionpack/lib/action_view/lookup_context.rb')
-rw-r--r-- | actionpack/lib/action_view/lookup_context.rb | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index d524c68450..14cccd88f0 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -78,17 +78,17 @@ module ActionView @view_paths = ActionView::Base.process_view_paths(paths) end - def find(name, prefix = nil, partial = false, keys = []) - @view_paths.find(*args_for_lookup(name, prefix, partial, keys)) + def find(name, prefixes = [], partial = false, keys = []) + @view_paths.find(*args_for_lookup(name, prefixes, partial, keys)) end alias :find_template :find - def find_all(name, prefix = nil, partial = false, keys = []) - @view_paths.find_all(*args_for_lookup(name, prefix, partial, keys)) + def find_all(name, prefixes = [], partial = false, keys = []) + @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys)) end - def exists?(name, prefix = nil, partial = false, keys = []) - @view_paths.exists?(*args_for_lookup(name, prefix, partial, keys)) + def exists?(name, prefixes = [], partial = false, keys = []) + @view_paths.exists?(*args_for_lookup(name, prefixes, partial, keys)) end alias :template_exists? :exists? @@ -107,18 +107,25 @@ module ActionView protected - def args_for_lookup(name, prefix, partial, keys) #:nodoc: - name, prefix = normalize_name(name, prefix) - [name, prefix, partial || false, @details, details_key, keys] + def args_for_lookup(name, prefixes, partial, keys) #:nodoc: + name, prefixes = normalize_name(name, prefixes) + [name, prefixes, partial || false, @details, details_key, keys] end # Support legacy foo.erb names even though we now ignore .erb # as well as incorrectly putting part of the path in the template # name instead of the prefix. - def normalize_name(name, prefix) #:nodoc: + def normalize_name(name, prefixes) #:nodoc: name = name.to_s.gsub(handlers_regexp, '') parts = name.split('/') - return parts.pop, [prefix, *parts].compact.join("/") + name = parts.pop + prx = if not prefixes or prefixes.empty? + [parts.compact.join('/')] + else + prefixes.map {|prefix| [prefix, *parts].compact.join('/') } + end + + return name, prx end def default_handlers #:nodoc: @@ -237,4 +244,4 @@ module ActionView include Details include ViewPaths end -end
\ No newline at end of file +end |