Skip to content

Instantly share code, notes, and snippets.

@eagleflo
Created August 13, 2014 13:39
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 eagleflo/a568b24cf621ab225689 to your computer and use it in GitHub Desktop.
Save eagleflo/a568b24cf621ab225689 to your computer and use it in GitHub Desktop.
Simple templating with Clojure using enlive
(ns eagleflow.posts
(:require [markdown.core :refer [md-to-html-string]]
[net.cgrand.enlive-html :as html]))
(defn single
"Return a single post from the file system as HTML."
[date title]
(md-to-html-string (slurp (str "posts/" date "-" title ".md"))))
(html/deftemplate post (clojure.java.io/file "public/index.html")
[content]
[:#post] (html/html-content content))
(defn render-post
"Render a stand-alone post."
[date title]
(post (single date title)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment