From 15c230f0ad3407409e52f217add7e1c17611ba8f Mon Sep 17 00:00:00 2001 From: gered Date: Sat, 1 Mar 2014 17:49:27 -0500 Subject: [PATCH] add functions to allow resetting of the jtwig function repository --- src/clj_jtwig/core.clj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/clj_jtwig/core.clj b/src/clj_jtwig/core.clj index 64e68f0..4e15b23 100644 --- a/src/clj_jtwig/core.clj +++ b/src/clj_jtwig/core.clj @@ -7,9 +7,17 @@ (com.lyncode.jtwig.functions JtwigFunction) (java.io File FileNotFoundException))) +(defn- create-function-repository [] + (new DefaultFunctionRepository (make-array JtwigFunction 0))) + ; we'll be reusing the same function repository object for all contexts created when rendering templates. ; any custom functions added will be added to this instance -(defonce functions (atom (new DefaultFunctionRepository (make-array JtwigFunction 0)))) +(defonce functions (atom (create-function-repository))) + +(defn reset-functions! + "removes any added custom template function handlers" + [] + (reset! functions (create-function-repository))) (defn- twig-fn-exists? [name] (try