Skip to content

Instantly share code, notes, and snippets.

@tnoborio
Created December 8, 2010 09:16
Show Gist options
  • Save tnoborio/733068 to your computer and use it in GitHub Desktop.
Save tnoborio/733068 to your computer and use it in GitHub Desktop.
(ns hoge
(require [net.cgrand.enlive-html :as en]))
(declare layout)
(def lookup {"layout" #'layout})
(defn parent-template [nodes]
(when-let [id (-> nodes
(en/select [[:meta (en/attr= :name "parent")]])
first :attrs :content)]
(var-get (lookup id))))
(defmacro inheriting [source args & forms]
`(let [child# (en/html-resource ~source)
parent# (parent-template child#)
source# (en/at parent#
[:main] (en/substitute (en/select child# [:body :> :*])))]
(comp en/emit* (en/snippet* source# ~args ~@forms))))
(def layout (en/html-resource "layout.html"))
(def text (inheriting "text.html")
[body]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment