Sha256: d480e988db6a44c4056ad71647b52809b8871a894d52b7b58c8c80289909f0b8
Contents?: true
Size: 838 Bytes
Versions: 11
Compression:
Stored size: 838 Bytes
Contents
module Innate module View module Etanni def self.call(action, string) etanni = View.compile(string){|s| Innate::Etanni.new(s) } html = etanni.result(action.binding, (action.view || action.method)) return html, 'text/html' end end end class Etanni SEPARATOR = "E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82" START = "\n<<#{SEPARATOR}.chomp\n" STOP = "\n#{SEPARATOR}\n" ADD = "_out_ << " def initialize(template) @template = template compile end def compile temp = @template.dup temp.gsub!(/<\?r\s+(.*?)\s+\?>/m, "#{STOP} \\1; #{ADD} #{START}") @compiled = "_out_ = #{START} #{temp} #{STOP} _out_" end def result(binding, filename = '<Etanni>') eval(@compiled, binding, filename).to_s.strip end end end
Version data entries
11 entries across 11 versions & 3 rubygems