lib/erb/formatter.rb in erb-formatter-0.4.0 vs lib/erb/formatter.rb in erb-formatter-0.4.1
- old
+ new
@@ -220,10 +220,12 @@
"\n#{indent}#{string}"
end
def format_text(text)
p format_text: text if @debug
+ return unless text
+
starting_space = text.match?(/\A\s/)
final_newlines_count = text.match(/(\s*)\z/m).captures.last.count("\n")
html << "\n" if final_newlines_count > 1
@@ -287,10 +289,10 @@
erb_pre_pos = 0
until erb_scanner.eos?
if erb_scanner.scan_until(erb_tags_regexp)
p PRE_MATCH: [erb_pre_pos, '..', erb_scanner.pre_match] if @debug
erb_pre_match = erb_scanner.pre_match
- erb_pre_match = erb_pre_match[erb_pre_pos..]
+ erb_pre_match = erb_pre_match[erb_pre_pos..].to_s
erb_pre_pos = erb_scanner.pos
erb_code = erb_tags[erb_scanner.captures.first]
format_text(erb_pre_match)