From 9731ef653b0ed57fcaca2b27d58bac524b74b8c3 Mon Sep 17 00:00:00 2001 From: Simon Jefford Date: Sun, 16 May 2010 01:22:30 +0100 Subject: [PATCH] Check blocks are not incorrectly detected when compiling erubis templates --- .../lib/action_view/template/handlers/erb.rb | 2 +- actionpack/test/controller/capture_test.rb | 5 +++++ .../test/fixtures/test/proper_block_detection.erb | 1 + 3 files changed, 7 insertions(+), 1 deletions(-) create mode 100644 actionpack/test/fixtures/test/proper_block_detection.erb diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index 705c2bf..2377464 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 06a5af6..d1dbd53 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 "Putting stuff in the 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 0000000..23564db --- /dev/null +++ b/actionpack/test/fixtures/test/proper_block_detection.erb @@ -0,0 +1 @@ +<%= @todo %> -- 1.7.1