f24682a32e339c3204844021c5c8dacd020c0a8b
1 (in-package :parenscript
)
3 (defun process-html-forms (forms) ; this needs a rewrite
5 (labels ((handle-form (form)
7 (push (format nil
"<~A/>"
8 (string-downcase (symbol-name form
))) res
))
14 (keywordp (first form
)))
15 (let ((node-name (string-downcase (symbol-name (first form
)))))
16 (push (format nil
"<~A>" node-name
) res
)
17 (map nil
#'handle-form
(cdr form
))
18 (push (format nil
"</~A>" node-name
) res
)))
22 (keywordp (caar form
)))
23 (let ((node-name (string-downcase (symbol-name (caar form
)))))
24 (push (format nil
"<~A" node-name
) res
)
26 (loop with attrs
= (cdar form
)
28 for attr-name
= (pop attrs
)
29 for attr-test
= (when (not (keywordp attr-name
))
30 (let ((test attr-name
))
31 (setf attr-name
(pop attrs
))
33 for attr-val
= (pop attrs
)
37 (+ ,(format nil
" ~A=\"" (string-downcase (symbol-name attr-name
)))
43 (push (format nil
" ~A=\"" (string-downcase (symbol-name attr-name
)))
48 (map nil
#'handle-form
(cdr form
))
49 (push (format nil
"</~A>" node-name
) res
)))
53 (map nil
#'handle-form forms
)
54 (concat-constant-strings (reverse res
)))))
56 (defpsmacro ps-html
(&rest html-forms
)
57 (cons '+ (process-html-forms html-forms
)))
59 (defmacro ps-html
(&rest html-forms
)
60 `(format nil
"~@{~A~}" ,@(process-html-forms html-forms
)))