aboutsummaryrefslogtreecommitdiff
path: root/src/guff/template-cache.cr
blob: 7a20179c3ad6ff37c09b79c3e9614584cd0c8869 (plain)
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