1 2 3 4 5 6 7 8 9 10 11 12
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