class SlimLint::Filters::ControlProcessor

A dumbed-down version of {Slim::Controls} which doesn't introduce temporary variables and other cruft (which in the context of extracting Ruby code, results in a lot of weird cops reported by RuboCop).

Constants

BLOCK_RE

Public Instance Methods

on_slim_control(code, content) click to toggle source

Handle control expression `[:slim, :control, code, content]`

@param code [String] @param content [Array]

# File lib/slim_lint/filters/control_processor.rb, line 14
def on_slim_control(code, content)
  [:multi,
    [:code, code],
    compile(content)]
end
on_slim_output(_escape, code, content) click to toggle source

Handle output expression `[:slim, :output, escape, code, content]`

@param _escape [Boolean] @param code [String] @param content [Array] @return [Array

# File lib/slim_lint/filters/control_processor.rb, line 26
def on_slim_output(_escape, code, content)
  if code[BLOCK_RE]
    [:multi,
      [:code, code, compile(content)],
      [:code, 'end']]
  else
    [:multi, [:dynamic, code], compile(content)]
  end
end
on_slim_text(_type, content) click to toggle source

Handle text expression `[:slim, :text, type, content]`

@param _type [Symbol] @param content [Array] @return [Array]

# File lib/slim_lint/filters/control_processor.rb, line 41
def on_slim_text(_type, content)
  # Ensures :newline expressions from static output are still represented in
  # the final expression
  compile(content)
end