diff options
author | Simon Jefford <simon.jefford@gmail.com> | 2010-05-16 01:22:30 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-05-16 15:05:07 +0200 |
commit | f58bdae1f716c71202546c5a40a951b5fc54a591 (patch) | |
tree | 2137defacc529f1f35c6eb85967e8ec83a6cb5c9 /actionpack | |
parent | 4ea48f2a9880508a4967be011345fc05570f44c4 (diff) | |
download | rails-f58bdae1f716c71202546c5a40a951b5fc54a591.tar.gz rails-f58bdae1f716c71202546c5a40a951b5fc54a591.tar.bz2 rails-f58bdae1f716c71202546c5a40a951b5fc54a591.zip |
Check blocks are not incorrectly detected when compiling erubis templates [#4575 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/template/handlers/erb.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/capture_test.rb | 5 | ||||
-rw-r--r-- | actionpack/test/fixtures/test/proper_block_detection.erb | 1 |
3 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index 705c2bf82e..237746437a 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -28,7 +28,7 @@ module ActionView src << "@output_buffer.safe_concat('" << escape_text(text) << "');" end - BLOCK_EXPR = /(do|\{)(\s*\|[^|]*\|)?\s*\Z/ + BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/ def add_expr_literal(src, code) if code =~ BLOCK_EXPR diff --git a/actionpack/test/controller/capture_test.rb b/actionpack/test/controller/capture_test.rb index 06a5af6b32..d1dbd535c4 100644 --- a/actionpack/test/controller/capture_test.rb +++ b/actionpack/test/controller/capture_test.rb @@ -61,6 +61,11 @@ class CaptureTest < ActionController::TestCase assert_equal expected_content_for_output, @response.body end + def test_proper_block_detection + @todo = "some todo" + get :proper_block_detection + end + private def expected_content_for_output "<title>Putting stuff in the title!</title>\n\nGreat stuff!" diff --git a/actionpack/test/fixtures/test/proper_block_detection.erb b/actionpack/test/fixtures/test/proper_block_detection.erb new file mode 100644 index 0000000000..23564dbcee --- /dev/null +++ b/actionpack/test/fixtures/test/proper_block_detection.erb @@ -0,0 +1 @@ +<%= @todo %> |