aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/base.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-11-26 03:59:23 +0000
committerRick Olson <technoweenie@gmail.com>2007-11-26 03:59:23 +0000
commit87e506da535118d77b58484a4e6e2d1cd9e13b53 (patch)
treefc80941c104799d584838ba8cc3b7954171d0e72 /actionpack/lib/action_view/base.rb
parent1af084ecda66a8e1b4eb3a51a07ebca85bf2e419 (diff)
downloadrails-87e506da535118d77b58484a4e6e2d1cd9e13b53.tar.gz
rails-87e506da535118d77b58484a4e6e2d1cd9e13b53.tar.bz2
rails-87e506da535118d77b58484a4e6e2d1cd9e13b53.zip
Add #prepend_view_path and #append_view_path instance methods on ActionController::Base for consistency with the class methods. [rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8214 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/base.rb')
-rw-r--r--actionpack/lib/action_view/base.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 9901f81d56..a12574a09f 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -265,7 +265,7 @@ module ActionView #:nodoc:
end
def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil)#:nodoc:
- @view_paths = view_paths.respond_to?(:find) ? view_paths : [*view_paths].compact
+ @view_paths = view_paths.respond_to?(:find) ? view_paths.dup : [*view_paths].compact
@assigns = assigns_for_first_render
@assigns_added = nil
@controller = controller
@@ -472,6 +472,26 @@ If you are rendering a subtemplate, you must now use controller-like partial syn
TEMPLATE_HANDLER_PREFERENCES[template_format] || DEFAULT_TEMPLATE_HANDLER_PREFERENCE
end
+ # Adds a view_path to the front of the view_paths array.
+ # This change affects the current request only.
+ #
+ # @template.prepend_view_path("views/default")
+ # @template.prepend_view_path(["views/default", "views/custom"])
+ #
+ def prepend_view_path(path)
+ @view_paths.unshift(*path)
+ end
+
+ # Adds a view_path to the end of the view_paths array.
+ # This change affects the current request only.
+ #
+ # @template.append_view_path("views/default")
+ # @template.append_view_path(["views/default", "views/custom"])
+ #
+ def append_view_path(path)
+ @view_paths.push(*path)
+ end
+
private
def find_full_template_path(template_path, extension)
file_name = "#{template_path}.#{extension}"