From 5f55559eae5a55831f1137704c1d6d252eacc4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Pluta?= Date: Sat, 13 Apr 2024 17:14:32 +0200 Subject: [PATCH] Add support for custom item and category producers --- src/packer/core.clj | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/packer/core.clj b/src/packer/core.clj index 1d7152a..ff7db21 100644 --- a/src/packer/core.clj +++ b/src/packer/core.clj @@ -6,14 +6,15 @@ (def profile #{:t-shirt :tablet}) (defn produce-category-name [category i18n] - (str "### " (get i18n category))) + (let [producer (or (:category-producer i18n) #(str "### " %))] + (producer (get i18n category)))) (defn produce-item [item nights i18n] (let [quantity (if (= (type (:quantity item)) java.lang.Long) (:quantity item) ((:quantity item) nights)) - quantity-long (long (Math/ceil quantity)) - quantity-string (if (> quantity-long 1) (str " x" quantity-long) "") - name (or (get i18n (:key item)) (:name item))] - (str "- [ ] " name quantity-string))) + quantity-long (long (Math/ceil quantity)) + name (or (get i18n (:key item)) (:name item)) + producer (or (:item-producer i18n) #(str "- [ ] " %1 (if (> %2 1) (str " x" %2) "")))] + (producer name quantity-long))) (defn produce-items [items nights i18n] (->> items