Wrap builtin element functions with macro
This commit is contained in:
parent
979489c15b
commit
169a0c1467
1 changed files with 9 additions and 10 deletions
|
@ -84,22 +84,21 @@ When given :ASCII and :ATTR, it's possible to insert html text as a children, e.
|
||||||
(setf (gethash :html *builtin-elements*) t)
|
(setf (gethash :html *builtin-elements*) t)
|
||||||
|
|
||||||
(defmacro define-builtin-element (element-name)
|
(defmacro define-builtin-element (element-name)
|
||||||
`(progn
|
(let ((%element-name (alexandria:symbolicate '% element-name)))
|
||||||
(defun ,element-name (&rest attrs-and-children)
|
`(progn
|
||||||
(multiple-value-bind (attrs children)
|
(defun ,%element-name (&rest attrs-and-children)
|
||||||
(split-attrs-and-children attrs-and-children)
|
(multiple-value-bind (attrs children)
|
||||||
(make-builtin-element :tag (string-downcase (mkstr ',element-name))
|
(split-attrs-and-children attrs-and-children)
|
||||||
:attrs attrs :children children)))
|
(make-builtin-element :tag (string-downcase (mkstr ',element-name))
|
||||||
(defun ,(alexandria:symbolicate element-name '*) (attrs children)
|
:attrs attrs :children children)))
|
||||||
(make-builtin-element :tag (string-downcase (mkstr ',element-name))
|
(defmacro ,element-name (&body attrs-and-children)
|
||||||
:attrs attrs :children children))))
|
`(,',%element-name ,@attrs-and-children)))))
|
||||||
|
|
||||||
(defmacro define-and-export-builtin-elements (&rest element-names)
|
(defmacro define-and-export-builtin-elements (&rest element-names)
|
||||||
`(progn
|
`(progn
|
||||||
,@(mapcan (lambda (e)
|
,@(mapcan (lambda (e)
|
||||||
(list `(define-builtin-element ,e)
|
(list `(define-builtin-element ,e)
|
||||||
`(setf (gethash (make-keyword ',e) *builtin-elements*) t)
|
`(setf (gethash (make-keyword ',e) *builtin-elements*) t)
|
||||||
`(setf (gethash (make-keyword ,(format nil "~a*" e)) *builtin-elements*) t)
|
|
||||||
`(export ',e)))
|
`(export ',e)))
|
||||||
element-names)))
|
element-names)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue