Class: Slim::DoInserter Private

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

Overview

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.

In Slim you don't need the do keyword sometimes. This filter adds the missing keyword.

  • 10.times | Hello

Constant Summary collapse

BLOCK_REGEX =

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

/(\A(if|unless|else|elsif|when|begin|rescue|ensure|case)\b)|\bdo\s*(\|[^\|]*\|\s*)?\Z/

Instance Method Summary collapse

Methods inherited from Filter

#on_slim_embedded, #on_slim_text

Instance Method Details

#on_slim_control(code, content) ⇒ 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 control expression [:slim, :control, code, content]

Parameters:

  • code (String)

    Ruby code

  • content (Array)

    Temple expression

Returns:

  • (Array)

    Compiled temple expression


17
18
19
20
# File 'lib/slim/do_inserter.rb', line 17

def on_slim_control(code, content)
  code = code + ' do' unless code =~ BLOCK_REGEX || empty_exp?(content)
  [:slim, :control, code, compile(content)]
end

#on_slim_output(escape, code, content) ⇒ 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 output expression [:slim, :output, escape, code, content]

Parameters:

  • escape (Boolean)

    Escape html

  • code (String)

    Ruby code

  • content (Array)

    Temple expression

Returns:

  • (Array)

    Compiled temple expression


28
29
30
31
# File 'lib/slim/do_inserter.rb', line 28

def on_slim_output(escape, code, content)
  code = code + ' do' unless code =~ BLOCK_REGEX || empty_exp?(content)
  [:slim, :output, escape, code, compile(content)]
end