require "hache" class HMote PATTERN = / ^[^\S\n]*(%)[^\S\n]*(.*?)(?:\n|\z) | # % single-line code (<\?)\s+(.*?)\s+\?> | # (\{\{!?)(.*?)\}\} # {{ escape }} or {{! unescape }} /mx def self.parse(template, context = self, vars = []) terms = template.split(PATTERN) parts = "Proc.new do |params, __o|\n params ||= {}; __o ||= ''\n" vars.each do |var| parts << sprintf("%s = params[%p]\n", var, var) end while (term = terms.shift) case term when "