Implement template-map
Return a map of templates based on their filenames as keywords. Could be better, as I understand right now it's not recursive.
This commit is contained in:
parent
b68614edca
commit
ba95015e26
|
@ -1,5 +1,17 @@
|
|||
(ns website.core
|
||||
:require [clojure.java.io :as io])
|
||||
(:require [clojure.java.io :as io]))
|
||||
|
||||
|
||||
(def template-dir "./site/templates")
|
||||
|
||||
;; Thank you https://clojure.org/api/cheatsheet
|
||||
(def template-map
|
||||
"Grab all files in the template directory and insert them into a map with
|
||||
the filenames as keyword keys"
|
||||
(let [files (filter #(.isFile %) (file-seq (io/file template-dir)))
|
||||
] (mapcat #(assoc {} (keyword (.getName %)) (slurp %)) files)))
|
||||
|
||||
|
||||
|
||||
(defn foo
|
||||
"I don't do a whole lot."
|
||||
|
|
Loading…
Reference in New Issue