Class: Slim::Translator::StaticTranslator Private
- 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
- #call(exp) ⇒ Object private
-
#initialize(opts = {}) ⇒ StaticTranslator
constructor
private
A new instance of StaticTranslator.
- #on_slim_output(escape, code, content) ⇒ Object private
- #on_static(text) ⇒ Object private
Methods inherited from Filter
#on_slim_control, #on_slim_embedded, #on_slim_text
Constructor Details
#initialize(opts = {}) ⇒ StaticTranslator
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.
Returns a new instance of StaticTranslator.
60 61 62 63 |
# File 'lib/slim/translator.rb', line 60 def initialize(opts = {}) super @translate = eval("proc {|string| #{[:tr_fn]}(string) }") end |
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.
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/slim/translator.rb', line 65 def call(exp) @text, @captures = ''.dup, [] result = compile(exp) text = @translate.call(@text) while text =~ /%(\d+)/ result << [:static, $`] << @captures[$1.to_i - 1] text = $' end result << [:static, text] 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.
82 83 84 85 86 |
# File 'lib/slim/translator.rb', line 82 def on_slim_output(escape, code, content) @captures << [:slim, :output, escape, code, content] @text << "%#{@captures.size}" [:multi] 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.
77 78 79 80 |
# File 'lib/slim/translator.rb', line 77 def on_static(text) @text << text [:multi] end |