From fba3fd8577f2a1e665e463257abd8ac4bcd7724f Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Tue, 13 Nov 2018 16:17:32 +0100 Subject: [PATCH] add &generated-at replacement --- src/leiningen/render.clj | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/leiningen/render.clj b/src/leiningen/render.clj index 28a515d..98d5fd2 100644 --- a/src/leiningen/render.clj +++ b/src/leiningen/render.clj @@ -1,7 +1,8 @@ (ns leiningen.render (:require [clojure.java.io :as io] [clojure.string :as string] - [markdown.core :as md])) + [markdown.core :as md]) + (:import java.time.LocalDateTime)) (def input-root "resources/page") @@ -93,11 +94,15 @@ (comment (particles-in-content "asd &particle:hullu")) +(defn now-str [] + (.toString (LocalDateTime/now))) + (defn fill-in-placeholders [context html page] (let [simple (-> html (string/replace #"&nav" (:navcode context)) (string/replace #"&content" (:content page)) - (string/replace #"&title" (get-in page [:metadata :title]))) + (string/replace #"&title" (get-in page [:metadata :title])) + (string/replace #"&generated-at" (now-str))) particles (particles-in-content simple)] (reduce (fn [result particle] (string/replace result @@ -110,6 +115,9 @@ (fill-in-placeholders {:navcode "hhh"} "&nav &content &particle:aside\n " {:content "dinge"}) + (fill-in-placeholders {:navcode "hhh"} + "&nav &content &particle:aside\n &generated-at" + {:content "dinge"}) ) (defn write-sites [context template sites]