Class: Slimi::Filters::OutputProtector Private

Inherits:
Base
  • Object
show all
Defined in:
lib/slimi/filters/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 Base

#on_slimi_control, #on_slimi_embedded, #on_slimi_position, #on_slimi_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.



37
38
39
40
41
42
43
# File 'lib/slimi/filters/embedded.rb', line 37

def call(exp)
  @protect = []
  @collected = +''
  @tag = "%#{object_id.abs.to_s(36)}%"
  super(exp)
  @collected
end

#on_slimi_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.



50
51
52
53
54
# File 'lib/slimi/filters/embedded.rb', line 50

def on_slimi_output(escape, text, content)
  @collected << @tag
  @protect << [:slimi, :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.



45
46
47
48
# File 'lib/slimi/filters/embedded.rb', line 45

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.



56
57
58
59
60
61
62
63
64
# File 'lib/slimi/filters/embedded.rb', line 56

def unprotect(text)
  block = [:multi]
  while text =~ /#{@tag}/
    block << [:static, Regexp.last_match.pre_match]
    block << @protect.shift
    text = Regexp.last_match.post_match
  end
  block << [:static, text]
end