From a9fa5e4a3555591990dfbec43323b09d1001d8a9 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 27 Oct 2023 16:29:43 +0200 Subject: [PATCH] Add inline-resources macro * allows inclusion of a whole folder in the "resources/" directory --- src/main/clj/dda/c4k_common/macros.clj | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/clj/dda/c4k_common/macros.clj diff --git a/src/main/clj/dda/c4k_common/macros.clj b/src/main/clj/dda/c4k_common/macros.clj new file mode 100644 index 0000000..22133b1 --- /dev/null +++ b/src/main/clj/dda/c4k_common/macros.clj @@ -0,0 +1,8 @@ +(ns dda.c4k-common.macros + (:require [clojure.java.io :as io])) + +(defmacro inline-resources [resource-path] + (let [files (.listFiles (io/file (io/resource resource-path))) + file-contents (map slurp files) + file-names (map #(str resource-path "/" (.getName %)) files)] + (zipmap file-names file-contents)))