Class: Slim::Translator::DynamicTranslator
- Defined in:
- lib/slim/translator.rb
Instance Method Summary collapse
Methods inherited from Filter
#on_slim_control, #on_slim_embedded, #on_slim_text
Instance Method Details
#call(exp) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/slim/translator.rb', line 90 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, "#{[:tr_fn]}(#{@text.inspect}).gsub(/%(\\d+)/) { #{@captures_var}[$1.to_i-1] }", [:multi]] else result << [:slim, :output, false, "#{[:tr_fn]}(#{@text.inspect})", [:multi]] end end |
#on_slim_output(escape, code, content) ⇒ Object
108 109 110 111 112 |
# File 'lib/slim/translator.rb', line 108 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
103 104 105 106 |
# File 'lib/slim/translator.rb', line 103 def on_static(text) @text << text [:multi] end |