Permalink
Browse files

Final tidy up on templates inheritance.

  • Loading branch information...
1 parent e03e1fd commit 51a7d9acdd4a01fb23e21be7a89e6440e51715e8 @josevalim josevalim committed Dec 27, 2010
View
6 actionpack/CHANGELOG
@@ -1,8 +1,10 @@
*Rails 3.1.0 (unreleased)*
-* brought back config.action_view.cache_template_loading, which allows to decide whether templates should be cached or not [Piotr Sarnacki]
+* Template lookup now searches further up in the inheritance chain. [Artemave]
-* url_for and named url helpers now accept :subdomain and :domain as options [Josh Kalderimis]
+* Brought back config.action_view.cache_template_loading, which allows to decide whether templates should be cached or not. [Piotr Sarnacki]
+
+* url_for and named url helpers now accept :subdomain and :domain as options, [Josh Kalderimis]
* The redirect route method now also accepts a hash of options which will only change the parts of the url in question, or an object which responds to call, allowing for redirects to be reused (check the documentation for examples). [Josh Kalderimis]
View
13 actionpack/lib/action_view/lookup_context.rb
@@ -119,13 +119,14 @@ def normalize_name(name, prefixes) #:nodoc:
name = name.to_s.gsub(handlers_regexp, '')
parts = name.split('/')
name = parts.pop
- prx = if prefixes.blank?
- [parts.compact.join('/')]
- else
- prefixes.map {|prefix| [prefix, *parts].compact.join('/') }
- end
- return name, prx
+ prefixes = if prefixes.blank?
+ [parts.join('/')]
+ else
+ prefixes.map { |prefix| [prefix, *parts].compact.join('/') }
+ end
+
+ return name, prefixes
end
def default_handlers #:nodoc:
View
9 actionpack/lib/action_view/path_set.rb
@@ -21,26 +21,21 @@ def find(*args)
def find_all(path, prefixes = [], *args)
prefixes.each do |prefix|
templates = []
-
each do |resolver|
templates.concat resolver.find_all(path, prefix, *args)
end
-
return templates unless templates.empty?
end
-
[]
end
def find_first(path, prefixes = [], *args)
prefixes.each do |prefix|
each do |resolver|
- if template = resolver.find_all(path, prefix, *args).first
- return template
- end
+ template = resolver.find_all(path, prefix, *args).first
+ return template if template
end
end
-
nil
end
View
2 actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -111,7 +111,7 @@ def find_partial
end
def find_template(path=@path, locals=@locals.keys)
- prefixes = path.include?(?/) ? [] : @view.controller._prefixes
+ prefixes = path.include?(?/) ? [] : @view.controller_prefixes
@lookup_context.find_template(path, prefixes, true, locals)
end
View
2 actionpack/lib/action_view/renderer/template_renderer.rb
@@ -43,7 +43,7 @@ def determine_template(options) #:nodoc:
if options.key?(:text)
Template::Text.new(options[:text], formats.try(:first))
elsif options.key?(:file)
- with_fallbacks { find_template(options[:file], [], false, keys) }
+ with_fallbacks { find_template(options[:file], options[:prefixes], false, keys) }
elsif options.key?(:inline)
handler = Template.handler_for_extension(options[:type] || "erb")
Template.new(options[:inline], "inline template", handler, :locals => keys)

0 comments on commit 51a7d9a

Please sign in to comment.