Module: Jade::Formatter::Body

Extended by:
Body, Helper
Included in:
Body
Defined in:
lib/jade/formatter/body.rb

Instance Method Summary collapse

Methods included from Helper

and_indent, dispatch_for, format_delimited, format_exposing, format_leading_comments, format_node, format_pattern, format_trailing_comment, format_type, format_type_atom, too_long?

Instance Method Details

#format(node, indent:, source:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/jade/formatter/body.rb', line 7

def format(node, indent:, source:)
  node => AST::Body(expressions:, dangling_comments:)

  if expressions.empty? && !dangling_comments.empty?
    dangling_comments
      .map { |tok| "#{INDENT * indent}#{tok.value}" }
      .join("\n")
  else
    join_expressions(expressions, indent, source:)
  end
end