add comments to document the options. add missing option toggle function
This commit is contained in:
parent
050cb114f4
commit
0bf32bdd67
|
@ -10,7 +10,20 @@
|
|||
(java.io File FileNotFoundException ByteArrayOutputStream)))
|
||||
|
||||
; global options
|
||||
(defonce options (atom {:cache-compiled-templates true
|
||||
(defonce options (atom {; true/false to enable/disable compiled template caching when using templates from
|
||||
; files only. this does not affect templates being rendered directly from strings
|
||||
:cache-compiled-templates true
|
||||
|
||||
; true/false to enable/disable file status checks (existance of file and last modification
|
||||
; date/time check). if true, these checks will be skipped ONLY if a compiled template for
|
||||
; the filepath given is cached already. if this is true and an attempt is made to render
|
||||
; a template which is not yet cached, these checks will still be run (this is to ensure that
|
||||
; templates can still be loaded and compiled the first time they are rendered).
|
||||
; if caching is completely disabled (via the above option), then this setting is ignored and
|
||||
; file status checks will always be performed.
|
||||
; this option is intended to help increase performance when you know in advance that your
|
||||
; templates will not be modified/deleted after they are first compiled and you want to skip
|
||||
; any unnecessary file I/O.
|
||||
:skip-file-status-checks false}))
|
||||
|
||||
(declare flush-template-cache!)
|
||||
|
@ -24,6 +37,15 @@
|
|||
(flush-template-cache!)
|
||||
(swap! options assoc :cache-compiled-templates enable?))
|
||||
|
||||
(defn toggle-file-status-check-skipping!
|
||||
"toggle file status checks on/off. if enabled, after a template is compiled and cached then the source file
|
||||
on disk is not rechecked for modifications, skipping any file I/O that would otherwise occur. the default
|
||||
for this option is false, meaning that normal file status checks will always be performed. this is probably
|
||||
what you want unless performance is critical and you know your template files will not be modified while
|
||||
the application is running."
|
||||
[enable?]
|
||||
(swap! options assoc :skip-file-status-checks enable?))
|
||||
|
||||
; cache of compiled templates. key is the file path. value is a map with :last-modified which is the source file's
|
||||
; last modification timestamp and :template which is a com.lyncode.jtwig.tree.api.Content object which has been
|
||||
; compiled already and can be rendered by calling it's 'render' method
|
||||
|
|
Reference in a new issue