module Guff class TemplateCache def initialize(@templates : Hash(Symbol, String)) @cache = {} of Symbol => Template end def [](key : Symbol) : Template raise "unknown template: #{key}" unless @templates[key]? @cache[key] ||= Template.new(@templates[key]) end end end