respect the setting of `setup:render-cache-active` for template caching

templates were being cached regardless of the value of `setup:render-cache-active` because its value wasn’t being tested
dev-gang-render
Matthew Butterick 2 years ago
parent d019908a93
commit 173f9376ea

@ -1 +1 @@
1646354264 1656290564

@ -481,7 +481,6 @@
[maybe-output-path] [maybe-output-path]
[(->output-path source-path)] [(->output-path source-path)]
[else #false])) [else #false]))
(define key (template-cache-key source-path output-path))
(define (cache-thunk) (define (cache-thunk)
(match source-path (match source-path
[(or (? markup-source?) (? markdown-source?)) [(or (? markup-source?) (? markdown-source?))
@ -495,13 +494,16 @@
get-fallback-template)]) get-fallback-template)])
(file-exists-or-has-source? (proc source-path output-path-ext)))] (file-exists-or-has-source? (proc source-path output-path-ext)))]
[_ #false])) [_ #false]))
(if (current-session-interactive?) (cond
;; don't cache templates in interactive session, for fresher reloads [(or (current-session-interactive?) (not (setup:render-cache-active source-path)))
;; this makes it possible to add template and have it show up in next render ;; don't cache templates in interactive session, for fresher reloads
(cache-thunk) ;; this makes it possible to add template and have it show up in next render
;; otherwise, within a rendering session, this will prevent repeat players like "template.html.p" (cache-thunk)]
;; from hitting the file cache repeatedly ;; otherwise, within a rendering session, this will prevent repeat players like "template.html.p"
(hash-ref! ram-cache key (λ () (cache-ref! key cache-thunk))))) ;; from hitting the file cache repeatedly
[else
(define key (template-cache-key source-path output-path))
(hash-ref! ram-cache key (λ () (cache-ref! key cache-thunk)))]))
(module-test-external (module-test-external
(require pollen/setup sugar/file sugar/coerce) (require pollen/setup sugar/file sugar/coerce)

Loading…
Cancel
Save