Created
December 8, 2010 09:16
-
-
Save tnoborio/733068 to your computer and use it in GitHub Desktop.
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 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