Skip to content

Commit 5a632a7

Browse files
authored
fixed handling of do-block and hyphen stripping (#30)
1 parent de56faf commit 5a632a7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/ruby_ast_gen/erb_to_ruby_transformer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def visit(node)
118118
when :code
119119
flush_static_block
120120
stripped_code = node[1].to_s.gsub("-", "").strip
121-
code = node[1].to_s.gsub("-", "")
121+
code = if node[1].strip.start_with?("-") then node[1].to_s.gsub("-", "") else node[1].to_s end
122122
# Using this to determine if we should throw a StandardError for "invalid" ERB
123123
if is_control_struct_start(stripped_code)
124124
@in_control_block = true
@@ -174,7 +174,7 @@ def lower_do_block(code)
174174
if (code_match = code.match(/do\s+(?:\|([^|]*)\|)?/) || code.end_with?('do'))
175175
if code.include?("=")
176176
@output << code
177-
elsif code.include?("end")
177+
elsif code.strip.end_with?("end")
178178
ast = extract_ast(code)
179179
if ast.is_a?(::Parser::AST::Node)
180180
case ast.type

0 commit comments

Comments
 (0)