rename cache related functions to better indicate they have side-effects
This commit is contained in:
parent
7b949c176f
commit
e423a658b3
|
@ -45,7 +45,7 @@
|
||||||
true
|
true
|
||||||
(> file-last-modified other-timestamp))))
|
(> file-last-modified other-timestamp))))
|
||||||
|
|
||||||
(defn- get-cached-compiled-template [^File file create-fn]
|
(defn- cache-compiled-template! [^File file create-fn]
|
||||||
(let [filepath (.getPath file)
|
(let [filepath (.getPath file)
|
||||||
cache-and-return! (fn []
|
cache-and-return! (fn []
|
||||||
(let [new-compiled-template (create-fn file)]
|
(let [new-compiled-template (create-fn file)]
|
||||||
|
@ -62,10 +62,10 @@
|
||||||
(:template cached)
|
(:template cached)
|
||||||
(cache-and-return!))))
|
(cache-and-return!))))
|
||||||
|
|
||||||
(defn- get-compiled-template [^File file]
|
(defn- compile-template! [^File file]
|
||||||
(if-not (.exists file)
|
(if-not (.exists file)
|
||||||
(throw (new FileNotFoundException (str "Template file \"" file "\" not found.")))
|
(throw (new FileNotFoundException (str "Template file \"" file "\" not found.")))
|
||||||
(get-cached-compiled-template
|
(cache-compiled-template!
|
||||||
file
|
file
|
||||||
(fn [file]
|
(fn [file]
|
||||||
(compile-template-file file)))))
|
(compile-template-file file)))))
|
||||||
|
@ -150,7 +150,7 @@
|
||||||
"renders a template from a file, using the values in model-map as the model for the template"
|
"renders a template from a file, using the values in model-map as the model for the template"
|
||||||
[filename model-map & [options]]
|
[filename model-map & [options]]
|
||||||
(let [file (new File filename)
|
(let [file (new File filename)
|
||||||
compiled-template (get-compiled-template file)]
|
compiled-template (compile-template! file)]
|
||||||
(render-compiled-template compiled-template model-map options)))
|
(render-compiled-template compiled-template model-map options)))
|
||||||
|
|
||||||
(defn render-resource
|
(defn render-resource
|
||||||
|
|
Reference in a new issue