require "hache" class HMote PATTERN = /^(\n)| # new lines. ^\s*(%)\s*(.*?)(?:\n|\Z)| # % code (<\?)\s+(.*?)\s+\?>| # (\{\{!?)(.*?)\}\} # {{ escaped }} or {{! unescaped }} /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 << "%s = params[%s]\n" % [var, var.inspect] end while term = terms.shift case term when "