Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (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]))
Add Comment
Please, Sign In to add comment