Improve
This commit is contained in:
parent
37e9016b13
commit
f9bf53042f
2 changed files with 31 additions and 35 deletions
src
|
@ -9,22 +9,20 @@
|
|||
#:defcomp))
|
||||
(in-package #:hsx/defhsx)
|
||||
|
||||
(defmacro defhsx (name element-type)
|
||||
`(defmacro ,name (&body body)
|
||||
`(%create-element ,',element-type ,@body)))
|
||||
|
||||
(defun %create-element (type &rest body)
|
||||
(multiple-value-bind (props children)
|
||||
(parse-body body)
|
||||
(create-element type props children)))
|
||||
|
||||
(defmacro defhsx (name element-type)
|
||||
`(defmacro ,name (&body body)
|
||||
`(%create-element ,',element-type ,@body)))
|
||||
|
||||
(defun parse-body (body)
|
||||
(cond (; plist
|
||||
(and (listp (first body))
|
||||
(cond ((and (listp (first body))
|
||||
(keywordp (first (first body))))
|
||||
(values (first body) (rest body)))
|
||||
(; inline-plist
|
||||
(keywordp (first body))
|
||||
((keywordp (first body))
|
||||
(loop :for thing :on body :by #'cddr
|
||||
:for (k v) := thing
|
||||
:when (and (keywordp k) v)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue