Created
August 13, 2014 13:39
-
-
Save eagleflo/a568b24cf621ab225689 to your computer and use it in GitHub Desktop.
Simple templating with Clojure using enlive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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