Add group package
This commit is contained in:
parent
1a909aa994
commit
d4275d6967
5 changed files with 56 additions and 4 deletions
|
@ -3,6 +3,8 @@
|
|||
(:import-from #:hsx/escaper
|
||||
#:escape-html-attribute
|
||||
#:escape-html-text-content)
|
||||
(:import-from #:hsx/group
|
||||
#:self-closing-tag-p)
|
||||
(:export #:element
|
||||
#:tag
|
||||
#:html-tag
|
||||
|
@ -84,7 +86,9 @@
|
|||
children)
|
||||
type-str)
|
||||
(format stream
|
||||
"<~a~a></~a>"
|
||||
(if (self-closing-tag-p type)
|
||||
"<~a~a>"
|
||||
"<~a~a></~a>")
|
||||
type-str
|
||||
(props->string props)
|
||||
type-str)))))
|
||||
|
|
26
src/group.lisp
Normal file
26
src/group.lisp
Normal file
|
@ -0,0 +1,26 @@
|
|||
(defpackage #:hsx/group
|
||||
(:use #:cl)
|
||||
(:import-from #:alexandria
|
||||
#:make-keyword
|
||||
#:symbolicate)
|
||||
(:export #:defgroup
|
||||
#:self-closing-tag-p))
|
||||
(in-package #:hsx/group)
|
||||
|
||||
(defun make-keyword-hash-table (symbols)
|
||||
(let ((ht (make-hash-table)))
|
||||
(mapcar (lambda (sym)
|
||||
(setf (gethash (make-keyword sym) ht) t))
|
||||
symbols)
|
||||
ht))
|
||||
|
||||
(defmacro defgroup (name &body symbols)
|
||||
(let ((p-name (symbolicate '* name '*)))
|
||||
`(progn
|
||||
(defparameter ,p-name (make-keyword-hash-table ',symbols))
|
||||
(defun ,(symbolicate name '-p) (keyword)
|
||||
(gethash keyword ,p-name)))))
|
||||
|
||||
(defgroup self-closing-tag
|
||||
area base br col embed hr img input keygen
|
||||
link meta param source track wbr)
|
Loading…
Add table
Add a link
Reference in a new issue