Class: Slim::Splat::Filter Private

Inherits:
Filter
  • Object
show all
Defined in:
lib/slim/splat/filter.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Methods inherited from Filter

#on_slim_control, #on_slim_embedded, #on_slim_output, #on_slim_text

Instance Method Details

#call(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
# File 'lib/slim/splat/filter.rb', line 8

def call(exp)
  @splat_options = nil
  exp = compile(exp)
  if @splat_options
    opts = options.to_hash.reject {|k,v| !Filter.options.valid_key?(k) }.inspect
    [:multi, [:code, "#{@splat_options} = #{opts}"], exp]
  else
    exp
  end
end

#on_html_attrs(*attrs) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Handle attributes expression [:html, :attrs, *attrs]



45
46
47
48
49
50
51
52
53
54
# File 'lib/slim/splat/filter.rb', line 45

def on_html_attrs(*attrs)
  if attrs.any? {|attr| splat?(attr) }
    builder, block = make_builder(attrs)
    [:multi,
     block,
     [:dynamic, "#{builder}.build_attrs"]]
  else
    super
  end
end

#on_html_tag(name, attrs, content = nil) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Handle tag expression [:html, :tag, name, attrs, content]



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/slim/splat/filter.rb', line 25

def on_html_tag(name, attrs, content = nil)
  return super if name != '*'
  builder, block = make_builder(attrs[2..-1])
  if content
    [:multi,
     block,
     [:slim, :output, false,
      "#{builder}.build_tag #{empty_exp?(content) ? '{}' : 'do'}",
      compile(content)]]
  else
    [:multi,
     block,
     [:dynamic, "#{builder}.build_tag"]]
  end
end