Class: Innate::Etanni
- Inherits:
-
Object
- Object
- Innate::Etanni
- Defined in:
- lib/innate/view/etanni.rb
Constant Summary collapse
- SEPARATOR =
"E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82"- START =
"\n<<#{SEPARATOR}.chomp\n"- STOP =
"\n#{SEPARATOR}\n"- ADD =
"_out_ << "
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(template) ⇒ Etanni
constructor
A new instance of Etanni.
- #result(binding, filename = '<Etanni>') ⇒ Object
Constructor Details
#initialize(template) ⇒ Etanni
18 19 20 21 |
# File 'lib/innate/view/etanni.rb', line 18 def initialize(template) @template = template compile end |
Instance Method Details
#compile ⇒ Object
23 24 25 26 27 |
# File 'lib/innate/view/etanni.rb', line 23 def compile temp = @template.dup temp.gsub!(/<\?r\s+(.*?)\s+\?>/m, "#{STOP} \\1; #{ADD} #{START}") @compiled = "_out_ = #{START} #{temp} #{STOP} _out_" end |
#result(binding, filename = '<Etanni>') ⇒ Object
29 30 31 |
# File 'lib/innate/view/etanni.rb', line 29 def result(binding, filename = '<Etanni>') eval(@compiled, binding, filename).to_s.strip end |