Skip to content

Commit

Permalink
Set template_format to html inside rjs templates so renders within it…
Browse files Browse the repository at this point in the history
… default to html.
  • Loading branch information
josh committed Dec 4, 2008
1 parent ab211bf commit 148aff2
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 23 deletions.
3 changes: 0 additions & 3 deletions actionpack/lib/action_view/base.rb
Expand Up @@ -327,9 +327,6 @@ def _pick_template(template_path)
elsif (first_render = @_render_stack.first) && first_render.respond_to?(:format_and_extension) &&
(template = self.view_paths["#{template_file_name}.#{first_render.format_and_extension}"])
template
elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"]
@template_format = :html
template
else
template = Template.new(template_path, view_paths)

Expand Down
1 change: 1 addition & 0 deletions actionpack/lib/action_view/template_handlers/rjs.rb
Expand Up @@ -4,6 +4,7 @@ class RJS < TemplateHandler
include Compilable

def compile(template)
"@template_format = :html;" +
"controller.response.content_type ||= Mime::JS;" +
"update_page do |page|;#{template.source}\nend"
end
Expand Down
14 changes: 0 additions & 14 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -246,15 +246,6 @@ def accessing_local_assigns_in_inline_template
:locals => { :local_name => name }
end

def helper_method_to_render_to_string(*args)
render_to_string(*args)
end
helper_method :helper_method_to_render_to_string

def render_html_only_partial_within_inline
render :inline => "Hello world <%= helper_method_to_render_to_string :partial => 'test/partial_with_only_html_version' %>"
end

def render_implicit_html_template
end

Expand Down Expand Up @@ -948,11 +939,6 @@ def test_accessing_local_assigns_in_inline_template
assert_equal "Goodbye, Local David", @response.body
end

def test_rendering_html_only_partial_within_inline_with_js
get :render_html_only_partial_within_inline, :format => :js
assert_equal "Hello world partial with only html version", @response.body
end

def test_render_in_an_rjs_template_should_pick_html_templates_when_available
[:js, "js"].each do |format|
assert_nothing_raised do
Expand Down
6 changes: 0 additions & 6 deletions actionpack/test/template/render_test.rb
Expand Up @@ -136,12 +136,6 @@ def test_render_partial_and_fallback_to_layout
assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" })
end

# TODO: The reason for this test is unclear, improve documentation
def test_render_js_partial_and_fallback_to_erb_layout
@view.template_format = :js
assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" })
end

# TODO: The reason for this test is unclear, improve documentation
def test_render_missing_xml_partial_and_raise_missing_template
@view.template_format = :xml
Expand Down

0 comments on commit 148aff2

Please sign in to comment.