summaryrefslogtreecommitdiff
path: root/src/render.lisp
blob: a073f310503ef0dfc201d9278fdf1174a552e176 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
;;;; render.lisp -- render protocol and tools

(in-package :dnd)

(defgeneric render (view object &key)
  (:documentation "Render OBJECT as VIEW. VIEW could be anything, but it is intended to
be a keyword for usin in EQL method specializers."))

(defmacro defrender (view (spec &rest kwargs) &body body)
  "A helper macro for defining specializations of render."
  (let ((viewvar (gensym)))
    `(defmethod render  ((,viewvar ,(if (eq t view) t `(eql ,view))) ,spec &key ,@kwargs)
       ,@body)))

(defmacro with-page ((&key title) &body body)
  "A helper macro fordefining some standard page boilerplate."
  (let ((title-var (gensym)))
   `(let ((,title-var ,title))
      (with-html-string
        (:doctype)
        (:html
         (:head
          (:title ,title-var))
         (:body
          (page-nav)
          ,@body))))))