web/dom: make-elements: improvements
This commit is contained in:
parent
2efd85c5af
commit
c83aa8a007
1 changed files with 8 additions and 10 deletions
18
web/dom.lisp
18
web/dom.lisp
|
@ -5,8 +5,7 @@
|
|||
(:local-nicknames (:util :scopes/util)
|
||||
(:alx :alexandria))
|
||||
(:export #:elem #:element #:void-element #:render
|
||||
#:dlist
|
||||
#:div #:label))
|
||||
#:dlist))
|
||||
|
||||
(in-package :scopes/web/dom)
|
||||
|
||||
|
@ -48,13 +47,13 @@
|
|||
(defmethod put ((el void-element))
|
||||
(start (tag el) (attrs el)))
|
||||
|
||||
(defmacro make-element (tag)
|
||||
`(defun ,tag (attrs &rest body)
|
||||
(elem ',tag attrs body)))
|
||||
|
||||
(defmacro make-elements (tags)
|
||||
(defmacro make-elements (tags &optional (elem-fn 'elem))
|
||||
`(progn
|
||||
,@(mapcar (lambda (tag) `(make-element ,tag)) tags)))
|
||||
,@(mapcan (lambda (tag) ;`(make-element ,tag)) tags)))
|
||||
(list `(defun ,tag (attrs &rest body)
|
||||
(funcall #',elem-fn ',tag attrs body))
|
||||
`(export ',tag)))
|
||||
tags)))
|
||||
|
||||
(eval-when (:compile-toplevel :load-toplevel :execute)
|
||||
(make-elements (div label)))
|
||||
|
@ -77,8 +76,7 @@
|
|||
|
||||
(defun render (&rest elems)
|
||||
(let ((*output* (make-string-output-stream)))
|
||||
(dolist (el elems)
|
||||
(put el))
|
||||
(put elems)
|
||||
(get-output-stream-string *output*)))
|
||||
|
||||
(defun start (tag attrs &key close)
|
||||
|
|
Loading…
Add table
Reference in a new issue