disable template cache in interactive session

dev-output-files-201008
Matthew Butterick 4 years ago
parent 123547f3cb
commit d96a9d9809

@ -1 +1 @@
1595187053 1599432650

@ -409,25 +409,26 @@
[(->output-path source-path)] [(->output-path source-path)]
[else #false])) [else #false]))
(define key (template-cache-key source-path output-path)) (define key (template-cache-key source-path output-path))
(hash-ref! ram-cache (define (cache-thunk)
;; within a session, this will prevent repeat players like "template.html.p" (match source-path
;; from hitting the file cache repeatedly [(or (? markup-source?) (? markdown-source?))
key ;; output-path may not have an extension
(λ () (define output-path-ext (cond
(cache-ref! key [(get-ext output-path)]
(λ () [(current-poly-target)]
(match source-path [else #false]))
[(or (? markup-source?) (? markdown-source?)) (for/or ([proc (list get-template-from-metas
;; output-path may not have an extension get-default-template
(define output-path-ext (cond get-fallback-template)])
[(get-ext output-path)] (file-exists-or-has-source? (proc source-path output-path-ext)))]
[(current-poly-target)] [_ #false]))
[else #false])) (if (current-session-interactive?)
(for/or ([proc (list get-template-from-metas ;; don't cache templates in interactive session, for fresher reloads
get-default-template ;; this makes it possible to add template and have it show up in next render
get-fallback-template)]) (cache-thunk)
(file-exists-or-has-source? (proc source-path output-path-ext)))] ;; otherwise, within a rendering session, this will prevent repeat players like "template.html.p"
[_ #false])))))) ;; from hitting the file cache repeatedly
(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