Class: Innate::Etanni
- Inherits:
-
Object
- Object
- Innate::Etanni
- Defined in:
- lib/innate/view/etanni.rb
Constant Summary collapse
- SEPARATOR =
"E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82"
- CHOMP =
"<<#{SEPARATOR}.chomp!"
- START =
"\n_out_ << #{CHOMP}\n"
- STOP =
"\n#{SEPARATOR}\n"
- REPLACEMENT =
"#{STOP}\\1#{START}"
Instance Method Summary collapse
- #compile(filename = @filename) ⇒ Object
-
#initialize(template, filename = '<Etanni>') ⇒ Etanni
constructor
A new instance of Etanni.
- #result(instance, filename = @filename) ⇒ Object
Constructor Details
#initialize(template, filename = '<Etanni>') ⇒ Etanni
Returns a new instance of Etanni.
21 22 23 24 25 |
# File 'lib/innate/view/etanni.rb', line 21 def initialize(template, filename = '<Etanni>') @template = template @filename = filename compile end |
Instance Method Details
#compile(filename = @filename) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/innate/view/etanni.rb', line 27 def compile(filename = @filename) temp = @template.strip temp.gsub!(/<\?r\s+(.*?)\s+\?>/m, REPLACEMENT) @compiled = eval("Proc.new{ _out_ = [#{CHOMP}]\n#{temp}#{STOP}_out_.join }", nil, @filename) end |
#result(instance, filename = @filename) ⇒ Object
34 35 36 |
# File 'lib/innate/view/etanni.rb', line 34 def result(instance, filename = @filename) instance.instance_eval(&@compiled) end |