Skip to content

Commit

Permalink
Merge e7b7b6f into 3b20ea4
Browse files Browse the repository at this point in the history
  • Loading branch information
flyerhzm committed Feb 21, 2021
2 parents 3b20ea4 + e7b7b6f commit 9d1fd62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/synvert/core/engine/erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ def decode_ruby_stmt(source)
end

def decode_ruby_output(source)
source.gsub(/@output_buffer.append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/m) { "<%=#{Regexp.last_match(1)}%>" }.gsub(
/@output_buffer.append= (.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/m
) { |m| "<%=#{m.sub('@output_buffer.append= ', '').sub(ERUBY_EXPR_SPLITTER, '')}%>" }
source.gsub(/@output_buffer.append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/m) {
"<%=#{Regexp.last_match(1)}%>"
}.gsub(/@output_buffer.append= (.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/m) { |m|
"<%=#{m.sub('@output_buffer.append= ', '').sub(ERUBY_EXPR_SPLITTER, '')}%>"
}
end

def decode_html_output(source)
Expand Down
4 changes: 3 additions & 1 deletion lib/synvert/core/rewriter/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def add_curly_brackets_if_necessary(code)
#
# strip_brackets("(1..100)") #=> "1..100"
def strip_brackets(code)
code.sub(/^\((.*)\)$/) { Regexp.last_match(1) }.sub(/^\[(.*)\]$/) { Regexp.last_match(1) }.sub(/^{(.*)}$/) { Regexp.last_match(1) }
code.sub(/^\((.*)\)$/) { Regexp.last_match(1) }.sub(/^\[(.*)\]$/) { Regexp.last_match(1) }.sub(/^{(.*)}$/) {
Regexp.last_match(1)
}
end
end
end

0 comments on commit 9d1fd62

Please sign in to comment.