aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJan Maurits Faber <jmfaber@supersaas.com>2010-11-06 15:13:56 +0100
committerMichael Koziarski <michael@koziarski.com>2010-11-08 09:55:55 +1300
commitf04ec6a227b702342d2fb841f94915499bf6101a (patch)
treef9484d2c29914df3ec1c8bc97a111a9b48611b2b /actionpack
parent697f4851b8bc4eb539b3e565e8b6349cafed8aaa (diff)
downloadrails-f04ec6a227b702342d2fb841f94915499bf6101a.tar.gz
rails-f04ec6a227b702342d2fb841f94915499bf6101a.tar.bz2
rails-f04ec6a227b702342d2fb841f94915499bf6101a.zip
Added support for Erubis <%== tag
<%== x %> is syntactic sugar for <%= raw(x) %> Signed-off-by: Michael Koziarski <michael@koziarski.com> [#5918 status:committed]
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/template/handlers/erb.rb6
-rw-r--r--actionpack/test/controller/new_base/render_template_test.rb10
2 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb
index b827610456..4c1f3d70ca 100644
--- a/actionpack/lib/action_view/template/handlers/erb.rb
+++ b/actionpack/lib/action_view/template/handlers/erb.rb
@@ -40,7 +40,11 @@ module ActionView
end
def add_expr_escaped(src, code)
- src << '@output_buffer.append= ' << escaped_expr(code) << ';'
+ if code =~ BLOCK_EXPR
+ src << "@output_buffer.safe_append= " << code
+ else
+ src << "@output_buffer.safe_concat((" << code << ").to_s);"
+ end
end
def add_postamble(src)
diff --git a/actionpack/test/controller/new_base/render_template_test.rb b/actionpack/test/controller/new_base/render_template_test.rb
index d31193a063..9899036fe8 100644
--- a/actionpack/test/controller/new_base/render_template_test.rb
+++ b/actionpack/test/controller/new_base/render_template_test.rb
@@ -9,6 +9,7 @@ module RenderTemplate
"locals.html.erb" => "The secret is <%= secret %>",
"xml_template.xml.builder" => "xml.html do\n xml.p 'Hello'\nend",
"with_raw.html.erb" => "Hello <%=raw '<strong>this is raw</strong>' %>",
+ "with_implicit_raw.html.erb"=> "Hello <%== '<strong>this is also raw</strong>' %>",
"test/with_json.html.erb" => "<%= render :template => 'test/with_json.json' %>",
"test/with_json.json.erb" => "<%= render :template => 'test/final' %>",
"test/final.json.erb" => "{ final: json }",
@@ -51,6 +52,10 @@ module RenderTemplate
render :template => "with_raw"
end
+ def with_implicit_raw
+ render :template => "with_implicit_raw"
+ end
+
def with_error
render :template => "test/with_error"
end
@@ -99,6 +104,11 @@ module RenderTemplate
assert_body "Hello <strong>this is raw</strong>"
assert_status 200
+
+ get :with_implicit_raw
+
+ assert_body "Hello <strong>this is also raw</strong>"
+ assert_status 200
end
test "rendering a template with renders another template with other format that renders other template in the same format" do