mirror of
https://github.com/logseq/logseq.git
synced 2026-05-04 02:46:45 +00:00
@@ -2257,31 +2257,3 @@
|
||||
value (:block/content block)
|
||||
new-value (string/replace value full_text new-full-text)]
|
||||
(save-block-aux! block new-value (:block/format block) {})))
|
||||
|
||||
(defn variable-rules
|
||||
[]
|
||||
{"today" (util/format "[[%s]]" (date/today))
|
||||
"yesterday" (util/format "[[%s]]" (date/yesterday))
|
||||
"tomorrow" (util/format "[[%s]]" (date/tomorrow))
|
||||
"time" (date/get-current-time)
|
||||
"current page" (util/format "[[%s]]"
|
||||
(or (state/get-current-page)
|
||||
(date/today)))})
|
||||
|
||||
;; TODO: programmable
|
||||
;; context information, date, current page
|
||||
(defn resolve-dynamic-template!
|
||||
[content]
|
||||
(string/replace content #"<%([^%].*?)%>"
|
||||
(fn [[_ match]]
|
||||
(let [match (string/trim match)]
|
||||
(cond
|
||||
(string/blank? match)
|
||||
""
|
||||
(get (variable-rules) (string/lower-case match))
|
||||
(get (variable-rules) (string/lower-case match))
|
||||
:else
|
||||
(if-let [nld (date/nld-parse match)]
|
||||
(let [date (tc/to-local-date-time nld)]
|
||||
(util/format "[[%s]]" (date/journal-name date)))
|
||||
match))))))
|
||||
|
||||
Reference in New Issue
Block a user