Class: Slim::Translator::DynamicTranslator Private

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


91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/slim/translator.rb', line 91

def call(exp)
  @captures_count, @captures_var, @text = 0, unique_name, ''

  result = compile(exp)

  if @captures_count > 0
    result.insert(1, [:code, "#{@captures_var}=[]"])
    result << [:slim, :output, false, "#{options[:tr_fn]}(#{@text.inspect}).gsub(/%(\\d+)/) { #{@captures_var}[$1.to_i-1] }", [:multi]]
  else
    result << [:slim, :output, false, "#{options[:tr_fn]}(#{@text.inspect})", [:multi]]
  end
end

#on_slim_output(escape, code, 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.


109
110
111
112
113
# File 'lib/slim/translator.rb', line 109

def on_slim_output(escape, code, content)
  @captures_count += 1
  @text << "%#{@captures_count}"
  [:capture, "#{@captures_var}[#{@captures_count-1}]", [:slim, :output, escape, code, content]]
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.


104
105
106
107
# File 'lib/slim/translator.rb', line 104

def on_static(text)
  @text << text
  [:multi]
end