kit-clj / kit

Lightweight, modular framework for scalable web development in Clojure
https://kit-clj.github.io/
MIT License
476 stars 44 forks source link

Have changes in Selmer template files propagated without needing an Integrant reset (during development). #126

Closed gerdint closed 8 months ago

gerdint commented 9 months ago

It feels odd that changes in Selmer templates do not have effect until you do an Integrant reset in the REPL. I know this is analogous to how code changes are handled (reset always needed), but since the template files are referenced from the source itself it seems logical that changes to them take effect immediately.

I do see the value of automatic caching/memoization in production. I tried disabling the caching by doing (selmer.parser/cache-off!) in the user.clj ns but this does not seem to help.

yogthos commented 9 months ago

If you update the init multimethod in the pages namespace as follows, and that should do the trick

(defmethod ig/init-key :reitit.routes/pages
  [_ {:keys [base-path]
      :or   {base-path ""}
      :as   opts}]
  (layout/init-selmer!)
  (when (= :dev (:env opts))
    (selmer.parser/cache-off!))
  [base-path (route-data opts) (page-routes opts)])
gerdint commented 9 months ago

Indeed. Perhaps it would be a good idea to add this to the stock pages component template?

yogthos commented 8 months ago

Yup, I've updated the module with the code.