From 77a10a38d7e7ae64b1f7c743984ac046ca404851 Mon Sep 17 00:00:00 2001 From: gered Date: Thu, 19 Jun 2014 18:11:39 -0400 Subject: [PATCH] add strict-mode option support --- src/clojure/clj_jtwig/core.clj | 9 +++++++-- src/clojure/clj_jtwig/options.clj | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/clojure/clj_jtwig/core.clj b/src/clojure/clj_jtwig/core.clj index 07a38c3..c4a3087 100644 --- a/src/clojure/clj_jtwig/core.clj +++ b/src/clojure/clj_jtwig/core.clj @@ -24,10 +24,15 @@ see clj-jtwig.options for the option keys you can specify here." [& opts] (doseq [[k v] (apply hash-map opts)] - (if (= :cache-compiled-templates k) + (cond + (= k :cache-compiled-templates) ; 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!)) + (flush-template-cache!) + + (= k :strict-mode) + (-> configuration .parse (.strictMode v))) + (swap! options assoc k v))) ; cache of compiled templates. key is the file path. value is a map with :last-modified which is the source file's diff --git a/src/clojure/clj_jtwig/options.clj b/src/clojure/clj_jtwig/options.clj index e9bbec7..49a9cfb 100644 --- a/src/clojure/clj_jtwig/options.clj +++ b/src/clojure/clj_jtwig/options.clj @@ -41,4 +41,7 @@ ; the root path (relative to the classpath) where web resources such as js, css, images are ; located. typically in your project structure this path will be located under the ; "resources" directory. - :web-resource-path-root "public"})) \ No newline at end of file + :web-resource-path-root "public" + + ; when enabled, exceptions will be thrown when attempting to use variables that do not exist + :strict-mode false})) \ No newline at end of file