This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-26
Channels
- # adventofcode (2)
- # babashka (17)
- # babashka-sci-dev (4)
- # beginners (8)
- # chlorine-clover (4)
- # clj-kondo (18)
- # clj-on-windows (1)
- # clojure (11)
- # clojure-india (12)
- # clojure-nl (1)
- # clojure-spec (9)
- # clojure-uk (3)
- # clojurescript (9)
- # conjure (3)
- # events (1)
- # graalvm (6)
- # lsp (6)
- # meander (4)
- # music (2)
- # off-topic (10)
- # other-languages (9)
- # re-frame (2)
- # releases (1)
- # reveal (8)
- # sci (1)
- # tools-deps (6)
I've been playing around with a data-driven approach to static sites lately. Write Hiccup in EDN, then make HTML out of it. I needed some kind of templating, so I figured, why not just pipe the EDN through SCI. So far, I'm really liking it! This EDN:
^{:teod.subcons/filewriter :teod.subcons.filewriter/hiccup-html
:teod.subcons/transformers [teod.subcons.sci/eval]}
(let [title "A data-driven approach to static sites"]
[:html [:head [:title title]
[:body [:main [:section
[:h1 {:style "color: #252525"} title]
[:p "Hello, world! 1+1 is " (+ 1 1) "!"]]]]]])
Turns into this HTML:
<html>
<head>
<title>A data-driven approach to static sites</title>
<body>
<main>
<section>
<h1 style="color: #252525">A data-driven approach to static sites</h1>
<p>Hello, world! 1+1 is 2!</p>
</section>
</main>
</body>
</head>
</html>
I figure providing a SCI environment with some default functions could be a nice extension point.
Slightly larger example: https://subcons.teod.eu/data-driven-site/🎉 3