Skip to content

Instantly share code, notes, and snippets.

@phunanon
Created December 7, 2023 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phunanon/5063028634442b7e4001d3e465d11bab to your computer and use it in GitHub Desktop.
Save phunanon/5063028634442b7e4001d3e465d11bab to your computer and use it in GitHub Desktop.
Builds HTML files with %dep.html% substitution
(import "phunanon/fs")
(import "phunanon/dotenv") ──────
(-> (dotenv) :www (var www))
(-> (ls "*.html")
(var names)
(juxt _ (map (comp read trim)))
(... kv-dict)
(var files))
(-> files
@(map-vals #(reduce #(replace (str '%' %1 '%' ) (files %1) %) % names))
@(map-keys @(str www "/"))
(map (... write)))
www
(function map-keys f d ───────────────────────────────────────────────────────
(.. dict (flat-map (fn [k v] [(f k) v]) d)))
(function map-vals f d
(.. dict (flat-map (fn [k v] [k (f v)]) d)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment