Module: Jade::Formatter::Calls

Extended by:
Calls, Helper
Included in:
Calls
Defined in:
lib/jade/formatter/calls.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

#render(callee_str, item_strs, trailing_comma, indent) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/jade/formatter/calls.rb', line 36

def render(callee_str, item_strs, trailing_comma, indent)
  inline = "#{callee_str}(#{item_strs.join(', ')})"

  if trailing_comma || too_long?(inline, indent)
    inner = item_strs
      .map { "#{it.then(&and_indent(indent + 1))}," }
      .join("\n")

    "#{callee_str.then(&and_indent(indent))}(\n#{inner}\n#{INDENT * indent})"
  else
    inline.then(&and_indent(indent))
  end
end