From a5878fab541af99ec5cf055b0ce574d8bb54ad1c Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 2 Mar 2014 14:35:18 -0500 Subject: [PATCH] always clear the cache when toggling it on/off --- src/clj_jtwig/core.clj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/clj_jtwig/core.clj b/src/clj_jtwig/core.clj index 8d5acc0..527af56 100644 --- a/src/clj_jtwig/core.clj +++ b/src/clj_jtwig/core.clj @@ -12,10 +12,15 @@ ; global options (defonce options (atom {:cache-compiled-templates true})) +(declare flush-template-cache!) + (defn toggle-compiled-template-caching! "toggle caching of compiled templates on/off. if off, every time a template is rendered from a file it will be re-loaded from disk and re-compiled before being rendered. caching is turned on by default." [enable?] + ; always clear the cache when toggling. this will help ensure that any possiblity of weird behaviour from + ; leftover stuff being stuck in the cache pre-toggle-on/off won't happen + (flush-template-cache!) (swap! options assoc :cache-compiled-templates enable?)) ; cache of compiled templates. key is the file path. value is a map with :last-modified which is the source file's