Skip to content

Commit f58bdae

Browse files
simonjeffordjosevalim
authored andcommitted
Check blocks are not incorrectly detected when compiling erubis templates [rails#4575 state:resolved]
Signed-off-by: José Valim <[email protected]>
1 parent 4ea48f2 commit f58bdae

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

actionpack/lib/action_view/template/handlers/erb.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def add_text(src, text)
2828
src << "@output_buffer.safe_concat('" << escape_text(text) << "');"
2929
end
3030

31-
BLOCK_EXPR = /(do|\{)(\s*\|[^|]*\|)?\s*\Z/
31+
BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/
3232

3333
def add_expr_literal(src, code)
3434
if code =~ BLOCK_EXPR

actionpack/test/controller/capture_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def test_non_erb_block_content_for
6161
assert_equal expected_content_for_output, @response.body
6262
end
6363

64+
def test_proper_block_detection
65+
@todo = "some todo"
66+
get :proper_block_detection
67+
end
68+
6469
private
6570
def expected_content_for_output
6671
"<title>Putting stuff in the title!</title>\n\nGreat stuff!"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= @todo %>

0 commit comments

Comments
 (0)