aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-07-02 21:38:58 -0500
committerJoshua Peek <josh@joshpeek.com>2008-07-02 21:38:58 -0500
commit3b3790a4351ba7c9d2711089c21f24fcedc11fc0 (patch)
tree5b51c79d8493bcbc42879933af1d3bbb8084f014
parent6c0edef26ee1c0e5f0964cae64c9f48da6daf1fa (diff)
downloadrails-3b3790a4351ba7c9d2711089c21f24fcedc11fc0.tar.gz
rails-3b3790a4351ba7c9d2711089c21f24fcedc11fc0.tar.bz2
rails-3b3790a4351ba7c9d2711089c21f24fcedc11fc0.zip
Deprecate :use_full_path render option. The supplying the option no longer has an effect.
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/base.rb10
-rw-r--r--actionpack/lib/action_view/base.rb12
-rw-r--r--actionpack/lib/action_view/partial_template.rb2
-rw-r--r--actionpack/lib/action_view/template.rb39
-rw-r--r--actionpack/lib/action_view/template_file.rb10
-rw-r--r--actionpack/test/controller/new_render_test.rb8
-rw-r--r--actionpack/test/template/render_test.rb4
8 files changed, 45 insertions, 42 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 5a5895d9b4..9d64b6f231 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* Deprecate :use_full_path render option. The supplying the option no longer has an effect [Josh Peek]
+
* Add :as option to render a collection of partials with a custom local variable name. #509 [Simon Jefford, Pratik Naik]
render :partial => 'other_people', :collection => @people, :as => :person
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 209cdfa686..02941bade9 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -858,7 +858,7 @@ module ActionController #:nodoc:
else
if file = options[:file]
- render_for_file(file, options[:status], options[:use_full_path], options[:locals] || {})
+ render_for_file(file, options[:status], nil, options[:locals] || {})
elsif template = options[:template]
render_for_file(template, options[:status], true, options[:locals] || {})
@@ -870,9 +870,9 @@ module ActionController #:nodoc:
elsif action_name = options[:action]
template = default_template_name(action_name.to_s)
if options[:layout] && !template_exempt_from_layout?(template)
- render_with_a_layout(:file => template, :status => options[:status], :use_full_path => true, :layout => true)
+ render_with_a_layout(:file => template, :status => options[:status], :layout => true)
else
- render_with_no_layout(:file => template, :status => options[:status], :use_full_path => true)
+ render_with_no_layout(:file => template, :status => options[:status])
end
elsif xml = options[:xml]
@@ -1097,10 +1097,10 @@ module ActionController #:nodoc:
private
- def render_for_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc:
+ def render_for_file(template_path, status = nil, use_full_path = nil, locals = {}) #:nodoc:
add_variables_to_assigns
logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger
- render_for_text(@template.render(:file => template_path, :use_full_path => use_full_path, :locals => locals), status)
+ render_for_text(@template.render(:file => template_path, :locals => locals), status)
end
def render_for_text(text = nil, status = nil, append_response = false) #:nodoc:
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 40a3b16e9f..a8c6e15ca3 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -232,12 +232,11 @@ module ActionView #:nodoc:
# The hash in <tt>local_assigns</tt> is made available as local variables.
def render(options = {}, local_assigns = {}, &block) #:nodoc:
if options.is_a?(String)
- render_file(options, true, local_assigns)
+ render_file(options, nil, local_assigns)
elsif options == :update
update_page(&block)
elsif options.is_a?(Hash)
- use_full_path = options[:use_full_path]
- options = options.reverse_merge(:locals => {}, :use_full_path => true)
+ options = options.reverse_merge(:locals => {})
if partial_layout = options.delete(:layout)
if block_given?
@@ -250,7 +249,7 @@ module ActionView #:nodoc:
end
end
elsif options[:file]
- render_file(options[:file], use_full_path || false, options[:locals])
+ render_file(options[:file], nil, options[:locals])
elsif options[:partial] && options[:collection]
render_partial_collection(options[:partial], options[:collection], options[:spacer_template], options[:locals], options[:as])
elsif options[:partial]
@@ -298,10 +297,9 @@ module ActionView #:nodoc:
end
private
- # Renders the template present at <tt>template_path</tt>. If <tt>use_full_path</tt> is set to true,
- # it's relative to the view_paths array, otherwise it's absolute. The hash in <tt>local_assigns</tt>
+ # Renders the template present at <tt>template_path</tt>. The hash in <tt>local_assigns</tt>
# is made available as local variables.
- def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc:
+ def render_file(template_path, use_full_path = nil, local_assigns = {}) #:nodoc:
if defined?(ActionMailer) && defined?(ActionMailer::Base) && controller.is_a?(ActionMailer::Base) && !template_path.include?("/")
raise ActionViewError, <<-END_ERROR
Due to changes in ActionMailer, you need to provide the mailer_name along with the template name.
diff --git a/actionpack/lib/action_view/partial_template.rb b/actionpack/lib/action_view/partial_template.rb
index a2129952c0..719199f19d 100644
--- a/actionpack/lib/action_view/partial_template.rb
+++ b/actionpack/lib/action_view/partial_template.rb
@@ -6,7 +6,7 @@ module ActionView #:nodoc:
@view_controller = view.controller if view.respond_to?(:controller)
@as = as
set_path_and_variable_name!(partial_path)
- super(view, @path, true, locals)
+ super(view, @path, nil, locals)
add_object_to_local_assigns!(object)
# This is needed here in order to compile template with knowledge of 'counter'
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 4c3f252c10..0cba1942f7 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -5,15 +5,19 @@ module ActionView #:nodoc:
attr_accessor :locals
attr_reader :handler, :path, :extension, :filename, :method
- def initialize(view, path, use_full_path, locals = {})
+ def initialize(view, path, use_full_path = nil, locals = {})
+ unless use_full_path == nil
+ ActiveSupport::Deprecation.warn("use_full_path option has been deprecated and has no affect.", caller)
+ end
+
@view = view
@paths = view.view_paths
@original_path = path
- @path = TemplateFile.from_path(path, !use_full_path)
+ @path = TemplateFile.from_path(path)
@view.first_render ||= @path.to_s
@source = nil # Don't read the source until we know that it is required
- set_extension_and_file_name(use_full_path)
+ set_extension_and_file_name
@locals = locals || {}
@handler = self.class.handler_class_for_extension(@extension).new(@view)
@@ -63,25 +67,24 @@ module ActionView #:nodoc:
end
private
- def set_extension_and_file_name(use_full_path)
+ def set_extension_and_file_name
@extension = @path.extension
- if use_full_path
- unless @extension
- @path = @view.send(:template_file_from_name, @path)
- raise_missing_template_exception unless @path
- @extension = @path.extension
- end
-
- if @path = @paths.find_template_file_for_path(path)
- @filename = @path.full_path
- @extension = @path.extension
- end
- else
- @filename = @path.full_path
+ unless @extension
+ @path = @view.send(:template_file_from_name, @path)
+ raise_missing_template_exception unless @path
+ @extension = @path.extension
end
- raise_missing_template_exception if @filename.blank?
+ if p = @paths.find_template_file_for_path(path)
+ @path = p
+ @filename = @path.full_path
+ @extension = @path.extension
+ raise_missing_template_exception if @filename.blank?
+ else
+ @filename = @original_path
+ raise_missing_template_exception unless File.exist?(@filename)
+ end
end
def raise_missing_template_exception
diff --git a/actionpack/lib/action_view/template_file.rb b/actionpack/lib/action_view/template_file.rb
index dd66482b3c..c38e8ed122 100644
--- a/actionpack/lib/action_view/template_file.rb
+++ b/actionpack/lib/action_view/template_file.rb
@@ -4,8 +4,8 @@ module ActionView #:nodoc:
# from the load path root e.g. "hello/index.html.erb" not
# "app/views/hello/index.html.erb"
class TemplateFile
- def self.from_path(path, use_full_path = false)
- path.is_a?(self) ? path : new(path, use_full_path)
+ def self.from_path(path)
+ path.is_a?(self) ? path : new(path)
end
def self.from_full_path(load_path, full_path)
@@ -17,11 +17,11 @@ module ActionView #:nodoc:
attr_accessor :load_path, :base_path, :name, :format, :extension
delegate :to_s, :inspect, :to => :path
- def initialize(path, use_full_path = false)
+ def initialize(path)
path = path.dup
- # Clear the forward slash in the beginning unless using full path
- trim_forward_slash!(path) unless use_full_path
+ # Clear the forward slash in the beginning
+ trim_forward_slash!(path)
@base_path, @name, @format, @extension = split(path)
end
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index 5a7da57559..d60bacd52a 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -81,12 +81,12 @@ class NewRenderTestController < ActionController::Base
def render_file_not_using_full_path
@secret = 'in the sauce'
- render :file => 'test/render_file_with_ivar', :use_full_path => true
+ render :file => 'test/render_file_with_ivar'
end
def render_file_not_using_full_path_with_dot_in_path
@secret = 'in the sauce'
- render :file => 'test/dot.directory/render_file_with_ivar', :use_full_path => true
+ render :file => 'test/dot.directory/render_file_with_ivar'
end
def render_xml_hello
@@ -231,13 +231,13 @@ class NewRenderTestController < ActionController::Base
end
def render_to_string_with_exception
- render_to_string :file => "exception that will not be caught - this will certainly not work", :use_full_path => true
+ render_to_string :file => "exception that will not be caught - this will certainly not work"
end
def render_to_string_with_caught_exception
@before = "i'm before the render"
begin
- render_to_string :file => "exception that will be caught- hope my future instance vars still work!", :use_full_path => true
+ render_to_string :file => "exception that will be caught- hope my future instance vars still work!"
rescue
end
@after = "i'm after the render"
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 5163c35189..726cf37026 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -12,7 +12,7 @@ class ViewRenderTest < Test::Unit::TestCase
end
def test_render_file_not_using_full_path
- assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb", :use_full_path => true)
+ assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb")
end
def test_render_file_without_specific_extension
@@ -21,7 +21,7 @@ class ViewRenderTest < Test::Unit::TestCase
def test_render_file_with_full_path
template_path = File.join(File.dirname(__FILE__), '../fixtures/test/hello_world.erb')
- assert_equal "Hello world!", @view.render(:file => template_path, :use_full_path => false)
+ assert_equal "Hello world!", @view.render(:file => template_path)
end
def test_render_file_with_instance_variables