From 7839e27b4e467b5cf94e83555b9b6f0a4f6aaf8a Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 20 Nov 2014 06:57:22 +0900 Subject: Some valid block calls in templates caused syntax errors Now ActionView accepts <%= foo(){ %> and <%= foo()do %> :golf: --- actionview/CHANGELOG.md | 5 +++++ actionview/lib/action_view/template/handlers/erb.rb | 2 +- actionview/test/fixtures/test/_label_with_block.erb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index e388e6ecd3..d7875def51 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,8 @@ +* Fix a bug that <%= foo(){ %> and <%= foo()do %> in view templates were not regarded + as Ruby block calls. + + * Akira Matsuda * + * Update `select_tag` to work correctly with `:include_blank` option passing a string. Fixes #16483. diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb index 3c2224fbf5..85a100ed4c 100644 --- a/actionview/lib/action_view/template/handlers/erb.rb +++ b/actionview/lib/action_view/template/handlers/erb.rb @@ -35,7 +35,7 @@ module ActionView end end - BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/ + BLOCK_EXPR = /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/ def add_expr_literal(src, code) flush_newline_if_pending(src) diff --git a/actionview/test/fixtures/test/_label_with_block.erb b/actionview/test/fixtures/test/_label_with_block.erb index 40117e594e..94089ea93d 100644 --- a/actionview/test/fixtures/test/_label_with_block.erb +++ b/actionview/test/fixtures/test/_label_with_block.erb @@ -1,4 +1,4 @@ -<%= label 'post', 'message' do %> +<%= label('post', 'message')do %> Message <%= text_field 'post', 'message' %> <% end %> -- cgit v1.2.3