Skip to content

Commit 3462768

Browse files
authored
fixed last files on chatwoot (#27)
1 parent 5c7a312 commit 3462768

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

lib/ruby_ast_gen/erb_to_ruby_transformer.rb

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def visit(node)
5151
inner_node = node[2]
5252
code = inner_node[1].to_s
5353

54-
if code.include?(" if ") || code.include?("unless")
54+
if code.include?(" if ") || code.include?(" unless ")
5555
parser_buffer = Parser::Source::Buffer.new("internal_tmp_#{Time.now.nsec}")
5656
parser_buffer.source = code
5757
ruby_parser = Parser::CurrentRuby.new
@@ -137,19 +137,25 @@ def flush_static_block()
137137

138138
def lower_do_block(code)
139139
if (code_match = code.match(/do\s+(?:\|([^|]*)\|)?/) || code.end_with?('do'))
140-
@current_lambda_vars = code_match[1]
141-
before_do, _ = code.split(/\bdo\b/)
142-
unless before_do.nil?
143-
method_call = before_do.strip
144-
call_name, rest = method_call.split(' ', 2)
145-
if rest != nil && !rest.start_with?('(') && !rest.end_with?(')')
146-
method_call = "#{call_name}(#{rest})"
140+
if code.include?("=")
141+
@output << code
142+
else
143+
@current_lambda_vars = code_match[1]
144+
before_do, _ = code.split(/\bdo\b/)
145+
unless before_do.nil?
146+
method_call = before_do.strip
147+
call_name, rest = method_call.split(' ', 2)
148+
if method_call.start_with?('[')
149+
method_call = method_call
150+
elsif rest != nil && !rest.start_with?('(') && !rest.end_with?(')')
151+
method_call = "#{call_name}(#{rest})"
152+
end
153+
@output << "#{@output_tmp_var} << #{method_call}"
147154
end
148-
@output << "#{@output_tmp_var} << #{method_call}"
155+
@in_do_block = true
156+
@output << "#{lambda_incrementor} = lambda do |#{@current_lambda_vars}|"
157+
@output << "#{@inner_buffer} = \"\""
149158
end
150-
@in_do_block = true
151-
@output << "#{lambda_incrementor} = lambda do |#{@current_lambda_vars}|"
152-
@output << "#{@inner_buffer} = \"\""
153159
end
154160
end
155161

0 commit comments

Comments
 (0)