add &generated-at replacement

master
Josha von Gizycki 6 years ago
parent e763984e59
commit fba3fd8577

@ -1,7 +1,8 @@
(ns leiningen.render (ns leiningen.render
(:require [clojure.java.io :as io] (:require [clojure.java.io :as io]
[clojure.string :as string] [clojure.string :as string]
[markdown.core :as md])) [markdown.core :as md])
(:import java.time.LocalDateTime))
(def input-root "resources/page") (def input-root "resources/page")
@ -93,11 +94,15 @@
(comment (comment
(particles-in-content "asd &particle:hullu")) (particles-in-content "asd &particle:hullu"))
(defn now-str []
(.toString (LocalDateTime/now)))
(defn fill-in-placeholders [context html page] (defn fill-in-placeholders [context html page]
(let [simple (-> html (let [simple (-> html
(string/replace #"&nav" (:navcode context)) (string/replace #"&nav" (:navcode context))
(string/replace #"&content" (:content page)) (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)] particles (particles-in-content simple)]
(reduce (fn [result particle] (reduce (fn [result particle]
(string/replace result (string/replace result
@ -110,6 +115,9 @@
(fill-in-placeholders {:navcode "hhh"} (fill-in-placeholders {:navcode "hhh"}
"&nav &content &particle:aside\n " "&nav &content &particle:aside\n "
{:content "dinge"}) {:content "dinge"})
(fill-in-placeholders {:navcode "hhh"}
"&nav &content &particle:aside\n &generated-at"
{:content "dinge"})
) )
(defn write-sites [context template sites] (defn write-sites [context template sites]

Loading…
Cancel
Save