Class: Slimi::Filters::Output

Inherits:
Base
  • Object
show all
Defined in:
lib/slimi/filters/output.rb

Overview

Handle ‘[:slimi, :output, escape, code, multi]`.

Constant Summary collapse

IF_REGEXP =
/\A(if|unless)\b|\bdo\s*(\|[^|]*\|)?\s*$/.freeze

Instance Method Summary collapse

Methods inherited from Base

#on_slimi_control, #on_slimi_embedded, #on_slimi_position, #on_slimi_text

Instance Method Details

#on_slimi_output(escape, code, multi) ⇒ Array

Parameters:

  • escape (Boolean)
  • code (String)
  • multi (Array)

Returns:

  • (Array)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/slimi/filters/output.rb', line 15

def on_slimi_output(escape, code, multi)
  if code.match?(IF_REGEXP)
    tmp = unique_name
    [
      :multi,
      [:block, "#{tmp} = #{code}", options[:disable_capture] ? compile(multi) : [:capture, unique_name, compile(multi)]],
      [:escape, escape, [:dynamic, tmp]]
    ]
  else
    [
      :multi,
      [:escape, escape, [:dynamic, code]],
      multi
    ]
  end
end