From f2806041dc940ded20776695bcaaf4cec60ee6e2 Mon Sep 17 00:00:00 2001 From: David Powell Date: Sat, 26 Nov 2011 23:01:10 +0000 Subject: [PATCH] Attach template names to deftemplate/defsnippet vars so that they can be introspected, enabling third-party support for template reloading. --- src/net/cgrand/enlive_html.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/net/cgrand/enlive_html.clj b/src/net/cgrand/enlive_html.clj index 9a9a998..f900e4f 100644 --- a/src/net/cgrand/enlive_html.clj +++ b/src/net/cgrand/enlive_html.clj @@ -578,19 +578,19 @@ (defmacro defsnippet "Define a named snippet -- equivalent to (def name (snippet source selector args ...))." [name source selector args & forms] - `(def ~name (snippet ~source ~selector ~args ~@forms))) + `(def ~(with-meta name {::templates source}) (snippet ~source ~selector ~args ~@forms))) (defmacro deftemplate "Defines a template as a function that returns a seq of strings." [name source args & forms] - `(def ~name (template ~source ~args ~@forms))) + `(def ~(with-meta name {::templates source}) (template ~source ~args ~@forms))) (defmacro defsnippets [source & specs] (let [xml-sym (gensym "xml")] `(let [~xml-sym (html-resource ~source)] ~@(for [[name selector args & forms] specs] - `(def ~name (snippet ~xml-sym ~selector ~args ~@forms)))))) + `(def ~(with-meta name {::templates source}) (snippet ~xml-sym ~selector ~args ~@forms)))))) ;; transformations