-
Notifications
You must be signed in to change notification settings - Fork 27
/
dynamic.lisp
32 lines (28 loc) · 850 Bytes
/
dynamic.lisp
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
27
28
29
30
31
32
(in-package :spinneret)
(defun expand-dynamic-tag (&rest args)
`(dynamic-tag ,@args))
(deftag dynamic-tag (body attrs &key name)
(unless name
(error "No tag name"))
(let ((empty? (null body))
(thunk (gensym (string 'dynamic-tag-thunk)))
(attrs (escape-attrs nil attrs)))
`(prog1 nil
(flet ((,thunk ()
,@(loop for expr in body
collect `(catch-output ,expr))))
(declare (dynamic-extent #',thunk))
(dynamic-tag* ,name
(list ,@attrs)
#',thunk
,empty?)))))
(defun expand-h* (&rest args)
(if *interpret*
(cons (heading-depth-heading)
args)
`(h* ,@args)))
(deftag h* (body attrs &key)
`(dynamic-tag
:name (heading-depth-heading)
,@attrs
,@body))