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)
|
(:local-nicknames (:util :scopes/util)
|
||||||
(:alx :alexandria))
|
(:alx :alexandria))
|
||||||
(:export #:elem #:element #:void-element #:render
|
(:export #:elem #:element #:void-element #:render
|
||||||
#:dlist
|
#:dlist))
|
||||||
#:div #:label))
|
|
||||||
|
|
||||||
(in-package :scopes/web/dom)
|
(in-package :scopes/web/dom)
|
||||||
|
|
||||||
|
@ -48,13 +47,13 @@
|
||||||
(defmethod put ((el void-element))
|
(defmethod put ((el void-element))
|
||||||
(start (tag el) (attrs el)))
|
(start (tag el) (attrs el)))
|
||||||
|
|
||||||
(defmacro make-element (tag)
|
(defmacro make-elements (tags &optional (elem-fn 'elem))
|
||||||
`(defun ,tag (attrs &rest body)
|
|
||||||
(elem ',tag attrs body)))
|
|
||||||
|
|
||||||
(defmacro make-elements (tags)
|
|
||||||
`(progn
|
`(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)
|
(eval-when (:compile-toplevel :load-toplevel :execute)
|
||||||
(make-elements (div label)))
|
(make-elements (div label)))
|
||||||
|
@ -77,8 +76,7 @@
|
||||||
|
|
||||||
(defun render (&rest elems)
|
(defun render (&rest elems)
|
||||||
(let ((*output* (make-string-output-stream)))
|
(let ((*output* (make-string-output-stream)))
|
||||||
(dolist (el elems)
|
(put elems)
|
||||||
(put el))
|
|
||||||
(get-output-stream-string *output*)))
|
(get-output-stream-string *output*)))
|
||||||
|
|
||||||
(defun start (tag attrs &key close)
|
(defun start (tag attrs &key close)
|
||||||
|
|
Loading…
Add table
Reference in a new issue