Class: Slim::Translator::StaticTranslator
- Inherits:
-
Filter
- Object
- Temple::HTML::Filter
- Filter
- Slim::Translator::StaticTranslator
show all
- Defined in:
- lib/slim/translator.rb
Instance Method Summary
collapse
Methods inherited from Filter
#on_slim_control, #on_slim_embedded, #on_slim_text
Constructor Details
Returns a new instance of StaticTranslator.
58
59
60
61
|
# File 'lib/slim/translator.rb', line 58
def initialize(opts = {})
super
@translate = eval("proc {|string| #{options[:tr_fn]}(string) }")
end
|
Instance Method Details
#call(exp) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/slim/translator.rb', line 63
def call(exp)
@text, @captures = '', []
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
80
81
82
83
84
|
# File 'lib/slim/translator.rb', line 80
def on_slim_output(escape, code, content)
@captures << [:slim, :output, escape, code, content]
@text << "%#{@captures.size}"
[:multi]
end
|
#on_static(text) ⇒ Object
75
76
77
78
|
# File 'lib/slim/translator.rb', line 75
def on_static(text)
@text << text
[:multi]
end
|