Class: SlimLint::Filters::MultiFlattener

Inherits:
SlimLint::Filter
  • Object
show all
Defined in:
lib/slim_lint/filters/multi_flattener.rb

Overview

Flattens nested multi expressions while respecting source locatoins.

Instance Method Summary collapse

Methods included from SlimLint::Filter::Overrides

#on_escape, #on_html_attr, #on_html_attrs, #on_html_comment, #on_html_condcomment, #on_html_js, #on_html_tag, #on_slim_control, #on_slim_output, #on_slim_text

Instance Method Details

#on_multi(*exps) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/slim_lint/filters/multi_flattener.rb', line 11

def on_multi(*exps)
  # If the multi contains a single element, just return the element
  return compile(exps.first) if exps.size == 1

  result = @self
  result.clear
  result.concat(@key)

  exps.each do |exp|
    exp = compile(exp)
    if exp.first == :multi
      result.concat(exp[1..])
    else
      result << exp
    end
  end

  result
end

#on_slim_embedded(*args) ⇒ Object



7
8
9
# File 'lib/slim_lint/filters/multi_flattener.rb', line 7

def on_slim_embedded(*args)
  @self
end