module Tempeh
Constants
- BLK_CLOSE
- BLK_OPEN
- HTML_ESCAPE
- PATTERN
- RAW_CLOSE
- RAW_OPEN
- STR_CLOSE
- STR_OPEN
- UNSAFE
- VERSION
Public Class Methods
cache()
click to toggle source
# File lib/tempeh.rb, line 33 def cache @cache ||= {} end
compile(str)
click to toggle source
# File lib/tempeh.rb, line 37 def compile(str) terms = str.split(PATTERN) parts = "proc { |args| __o = '';" while (term = terms.shift) case term when BLK_OPEN then parts << "#{terms.shift}\n" when RAW_OPEN then parts << "__o << (#{terms.shift}).to_s\n" when STR_OPEN then parts << "__o << Tempeh.escape((#{terms.shift}).to_s)\n" else parts << "__o << #{term.dump}\n" end end parts << "__o; }" eval(parts) end
escape(str)
click to toggle source
# File lib/tempeh.rb, line 56 def escape(str) str.gsub(UNSAFE, HTML_ESCAPE) end
Public Instance Methods
test()
click to toggle source
# File lib/tempeh.rb, line 61 def test b = binding p = proc { b.eval("a = 22") } p.call puts a end