1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
module Guff class TemplateToken getter :type def initialize(@type : Symbol, @val : String) end def get(args : Hash(String, String)) case @type when :key raise "missing key: #{@val}" unless args.has_key?(@val) args[@val] when :val @val else # never reached raise "unknown token type: #{@type}" end end end end