Skip to content

Commit

Permalink
Check blocks are not incorrectly detected when compiling erubis templ…
Browse files Browse the repository at this point in the history
…ates [#4575 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
simonjefford authored and josevalim committed May 16, 2010
1 parent 4ea48f2 commit f58bdae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/template/handlers/erb.rb
Expand Up @@ -28,7 +28,7 @@ def add_text(src, text)
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
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/controller/capture_test.rb
Expand Up @@ -61,6 +61,11 @@ def test_non_erb_block_content_for
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!"
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/fixtures/test/proper_block_detection.erb
@@ -0,0 +1 @@
<%= @todo %>

0 comments on commit f58bdae

Please sign in to comment.