Class: Slim::Translator::DynamicTranslator Private

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

API:

  • private

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.

API:

  • private



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

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

  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.

API:

  • private



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

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.

API:

  • private



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

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