Ticket #8582: per_request_view_paths.diff
| File per_request_view_paths.diff, 3.0 kB (added by dasil003, 2 years ago) |
|---|
-
actionpack/lib/action_view/base.rb
old new 156 156 attr_accessor :base_path, :assigns, :template_extension 157 157 attr_accessor :controller 158 158 159 attr_reader :logger, :response, :headers , :view_paths159 attr_reader :logger, :response, :headers 160 160 attr_internal :cookies, :flash, :headers, :params, :request, :response, :session 161 161 162 162 attr_writer :template_format … … 267 267 else 268 268 template_extension = pick_template_extension(template_path).to_s 269 269 unless template_extension 270 raise ActionViewError, "No #{template_handler_preferences.to_sentence} template found for #{template_path} in #{ @view_paths.inspect}"270 raise ActionViewError, "No #{template_handler_preferences.to_sentence} template found for #{template_path} in #{view_paths.inspect}" 271 271 end 272 272 template_file_name = full_template_path(template_path, template_extension) 273 273 template_extension = template_extension.gsub(/^\w+\./, '') # strip off any formats … … 279 279 template_source = nil # Don't read the source until we know that it is required 280 280 281 281 if template_file_name.blank? 282 raise ActionViewError, "Couldn't find template file for #{template_path} in #{ @view_paths.inspect}"282 raise ActionViewError, "Couldn't find template file for #{template_path} in #{view_paths.inspect}" 283 283 end 284 284 285 285 begin … … 293 293 end 294 294 end 295 295 end 296 296 297 297 # Renders the template present at <tt>template_path</tt> (relative to the view_paths array). 298 298 # The hash in <tt>local_assigns</tt> is made available as local variables. 299 299 def render(options = {}, old_local_assigns = {}, &block) #:nodoc: … … 432 432 TEMPLATE_HANDLER_PREFERENCES[template_format] || DEFAULT_TEMPLATE_HANDLER_PREFERENCE 433 433 end 434 434 435 def view_paths 436 if @controller 437 @controller.view_paths 438 else 439 @view_paths 440 end 441 end 442 435 443 private 436 444 def find_full_template_path(template_path, extension) 437 445 file_name = "#{template_path}.#{extension}" … … 450 458 template_path_without_extension = template_path.sub(/\.(\w+)$/, '') 451 459 [ template_path_without_extension, $1 ] 452 460 end 453 461 454 462 # Returns the view path that contains the given relative template path. 455 463 def find_base_path_for(template_file_name) 456 @view_paths.find { |p| File.file?(File.join(p, template_file_name)) }464 view_paths.find { |p| File.file?(File.join(p, template_file_name)) } 457 465 end 458 466 459 467 # Returns the view path that the full path resides in. 460 468 def extract_base_path_from(full_path) 461 @view_paths.find { |p| full_path[0..p.size - 1] == p }469 view_paths.find { |p| full_path[0..p.size - 1] == p } 462 470 end 463 471 464 472 # Determines the template's file extension, such as rhtml, rxml, or rjs.