Skip to content

Commit

Permalink
Fixed that partial rendering should look at the type of the first ren…
Browse files Browse the repository at this point in the history
…der to determine its own type if no other clues are available (like when using text.plain.erb as the extension in AM) (closes #10130) [java] Fixed that partials would be broken when using text.plain.erb as the extension #10130 [java]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8166 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Nov 18, 2007
1 parent 713ca51 commit a76490d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions actionmailer/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN*

* Fixed that partials would be broken when using text.plain.erb as the extension #10130 [java]

* Update README to use new smtp settings configuration API. Closes #10060 [psq]

* Allow ActionMailer subclasses to individually set their delivery method (so two subclasses can have different delivery methods) #10033 [zdennis]
Expand Down
11 changes: 11 additions & 0 deletions actionmailer/test/mail_render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def rxml_template(recipient)
subject "rendering rxml template"
from "tester@example.com"
end

def included_subtemplate(recipient)
recipients recipient
subject "Including another template in the one being rendered"
from "tester@example.com"
end

def initialize_defaults(method_name)
super
Expand Down Expand Up @@ -70,6 +76,11 @@ def test_rxml_template
mail = RenderMailer.deliver_rxml_template(@recipient)
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip
end

def test_included_subtemplate
mail = RenderMailer.deliver_included_subtemplate(@recipient)
assert_equal "Hey Ho, let's go!", mail.body.strip
end
end

class FirstSecondHelperTest < Test::Unit::TestCase
Expand Down
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN*

* Fixed that partial rendering should look at the type of the first render to determine its own type if no other clues are available (like when using text.plain.erb as the extension in AM) #10130 [java]

* Fixed that has_many :through associations should render as collections too #9051 [mathie/danger]

* Added :mouseover short-cut to AssetTagHelper#image_tag for doing easy image swaps #6893 [joost]
Expand Down
12 changes: 10 additions & 2 deletions actionpack/lib/action_view/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc
raise ActionViewError, "No #{template_handler_preferences.to_sentence} template found for #{template_path} in #{view_paths.inspect}"
end
template_file_name = full_template_path(template_path, template_extension)
template_extension = template_extension.gsub(/^\w+\./, '') # strip off any formats
template_extension = template_extension.gsub(/^.+\./, '') # strip off any formats
end
else
template_file_name = template_path
Expand Down Expand Up @@ -490,7 +490,9 @@ def extract_base_path_from(full_path)

# Determines the template's file extension, such as rhtml, rxml, or rjs.
def find_template_extension_for(template_path)
find_template_extension_from_handler(template_path, true) || find_template_extension_from_handler(template_path)
find_template_extension_from_handler(template_path, true) ||
find_template_extension_from_handler(template_path) ||
find_template_extension_from_first_render()
end

def find_template_extension_from_handler(template_path, formatted = nil)
Expand All @@ -511,6 +513,12 @@ def find_template_extension_from_handler(template_path, formatted = nil)
end
nil
end

# Determine the template extension from the <tt>@first_render</tt> filename
def find_template_extension_from_first_render
extension = @first_render.to_s.sub /^\w+\.?/, ''
extension.blank? ? nil : extension
end

# This method reads a template file.
def read_template_file(template_path, extension)
Expand Down

0 comments on commit a76490d

Please sign in to comment.