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
# File 'lib/slim/embedded.rb', line 32

def call(exp)
  @protect, @collected, @tag = [], '', object_id.abs.to_s(36)
  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.



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

def on_slim_output(escape, text, content)
  @collected << "%#{@tag}%#{@protect.length}%"
  @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.



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

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.



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

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