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.



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

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]

Parameters:

  • attrs (Array)

    Array of temple expressions

Returns:

  • (Array)

    Compiled temple expression



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

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]

Parameters:

  • name (String)

    Tag name

  • attrs (Array)

    Temple expression

  • content (Array) (defaults to: nil)

    Temple expression

Returns:

  • (Array)

    Compiled temple expression



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

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