           (do
             (.append sb (:token (:body node)))
             (recur (rest ast)))
-          (throw (Exception. "there should only be AST nodes of type :string")))
+          (throw (Exception.
+                  (str "there should only be AST nodes of type :string, got: "
+                       node))))
         (str sb)))))
 
 (defn parse [s context]
   (-> s
       lex
       ast
-      (parse-tags context)
+      parse-tags
+      (interpret-tags context)
       (parse-filters context)))
 
 (def render (comp realize parse))

              :body token}
             (ast (rest tokens)))))))

(defn load-template [template]
  (-> (Thread/currentThread)
      (.getContextClassLoader)
      (.getResource template)
      slurp))

(defn parse-tags [ast context]
  (lazy-seq
   (when-let [node (first ast)]
     (if (= :tag (:type node))
       (let [[tag & args] (.split (.trim (:token (:body node))) " ")]
         (case tag
           "include" (let [[template] args
                           template (second (re-find #"\"(.*)\"" template))]
                       (concat (parse (load-template template) context)
                               (parse-tags (rest ast) context)))
           (throw (Exception. (str "unknown tag: " node)))))
       (cons node (parse-tags (rest ast) context))))))

(defn parse-filters [ast context]
  (lazy-seq

(ns clabango.parser
  (:use [clabango.filters :only [template-filter]]
        [clabango.tags :only [template-tag]]))

(declare parse)

