Skip to content

Commit

Permalink
Rename ERB_OPEN_BLOCK to RUBY_OPEN_BLOCK
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 6d9eb9a commit 0345476
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/erb/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Error < StandardError; end

SELF_CLOSING_TAG = /\A(area|base|br|col|command|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)\z/i

ERB_OPEN_BLOCK = ->(code) do
RUBY_OPEN_BLOCK = ->(code) do
# is nil when the parsing is broken, meaning it's an open expression
Ripper.sexp(code).nil?
end.freeze
Expand Down Expand Up @@ -170,7 +170,7 @@ def format_erb_attributes(string)
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 ERB_OPEN_BLOCK
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
Expand Down Expand Up @@ -258,8 +258,8 @@ def format_text(text)

def format_ruby(code, autoclose: false)
if autoclose
code += "\nend" unless ERB_OPEN_BLOCK["#{code}\nend"]
code += "\n}" unless ERB_OPEN_BLOCK["#{code}\n}"]
code += "\nend" unless RUBY_OPEN_BLOCK["#{code}\nend"]
code += "\n}" unless RUBY_OPEN_BLOCK["#{code}\n}"]
end
p RUBY_IN_: code if @debug

Expand Down Expand Up @@ -312,7 +312,7 @@ def format_erb_tags(string)
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 ERB_OPEN_BLOCK
when RUBY_OPEN_BLOCK
full_erb_tag = "#{erb_open}#{ruby_code} #{erb_close}"
html << (erb_pre_match.match?(/\s+\z/) ? indented(full_erb_tag) : full_erb_tag)
tag_stack_push('%erb%', ruby_code)
Expand Down

0 comments on commit 0345476

Please sign in to comment.