class Temple::Filters::Escapable
def compile(exp)
def compile(exp) return exp if !exp.is_a?(Enumerable) || exp.is_a?(String) if is_escape?(exp) case exp[1][0] when :static [:static, eval(@escaper % exp[1][1].inspect)] when :dynamic, :block [exp[1][0], @escaper % exp[1][1]] else raise "Escapable can only handle :static, :dynamic and :block for the moment." end else exp.map { |e| compile(e) } end end
def initialize(options = {})
def initialize(options = {}) @escaper = options[:escaper] || 'CGI.escapeHTML((%s).to_s)' end
def is_escape?(exp)
def is_escape?(exp) exp.respond_to?(:[]) && exp[0] == :escape end