Class: Slim::OutputProtector Private

Inherits:
Filter
  • Object
show all
Defined in:
lib/slim/embedded.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_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.



32
33
34
35
36
37
# File 'lib/slim/embedded.rb', line 32

def call(exp)
  @protect = []
  @collected = ''
  super(exp)
  @collected
end

#on_slim_output(escape, text, content) ⇒ 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.



44
45
46
47
48
# File 'lib/slim/embedded.rb', line 44

def on_slim_output(escape, text, content)
  @collected << "pro#{@protect.size}tect"
  @protect << [:slim, :output, escape, text, content]
  nil
end

#on_static(text) ⇒ 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.



39
40
41
42
# File 'lib/slim/embedded.rb', line 39

def on_static(text)
  @collected << text
  nil
end

#unprotect(text) ⇒ 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.



50
51
52
53
54
55
56
57
58
# File 'lib/slim/embedded.rb', line 50

def unprotect(text)
  block = [:multi]
  while text =~ /pro(\d+)tect/
    block << [:static, $`]
    block << @protect[$1.to_i]
    text = $'
  end
  block << [:static, text]
end