Skip to content

Commit

Permalink
Remove unused format_erb_attributes method
Browse files Browse the repository at this point in the history
Co-authored-by: Elia Schito <[email protected]>
  • Loading branch information
FrancescoAiello01 and elia committed Mar 31, 2023
1 parent e842ad0 commit ffa3e17
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions lib/erb/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,45 +146,6 @@ def format_attributes(tag_name, attrs, tag_closing)
attr_html
end

def format_erb_attributes(string)
erb_scanner = StringScanner.new(string.to_s)
erb_pre_pos = 0
until erb_scanner.eos?
if erb_scanner.scan_until(erb_tags_regexp)
erb_pre_match = erb_scanner.pre_match
erb_pre_match = erb_pre_match[erb_pre_pos..]
erb_pre_pos = erb_scanner.pos

erb_code = erb_tags[erb_scanner.captures.first]

format_attributes(erb_pre_match)

erb_open, ruby_code, erb_close = ERB_TAG.match(erb_code).captures
full_erb_tag = "#{erb_open} #{ruby_code} #{erb_close}"

case ruby_code
when /\Aend\z/
tag_stack_pop('%erb%', ruby_code)
html << (erb_pre_match.match?(/\s+\z/) ? indented(full_erb_tag) : full_erb_tag)
when /\A(else|elsif\b(.*))\z/
tag_stack_pop('%erb%', ruby_code)
html << (erb_pre_match.match?(/\s+\z/) ? indented(full_erb_tag) : full_erb_tag)
tag_stack_push('%erb%', ruby_code)
when RUBY_OPEN_BLOCK
html << (erb_pre_match.match?(/\s+\z/) ? indented(full_erb_tag) : full_erb_tag)
tag_stack_push('%erb%', ruby_code)
else
ruby_code = format_ruby(ruby_code, autoclose: false)
html << (erb_pre_match.match?(/\s+\z/) ? indented(full_erb_tag) : full_erb_tag)
end
else
rest = erb_scanner.rest.to_s
format_erb_attributes(rest)
erb_scanner.terminate
end
end
end

def tag_stack_push(tag_name, code)
tag_stack << [tag_name, code]
p PUSH: tag_stack if @debug
Expand Down

0 comments on commit ffa3e17

Please sign in to comment.