Introduce a new low level creation for clog element: 'create-element' #286

This commit is contained in:
Jingtao Xu 2024-01-16 10:24:40 +08:00
parent f5420f9f24
commit 4d69a28aa8
3 changed files with 29 additions and 0 deletions

1
.gitignore vendored
View file

@ -18,3 +18,4 @@
*.wx32fsl
*~
*.bak
*.64yfasl

View file

@ -71,6 +71,33 @@ CONNECTION-ID to it and then return it. The HTML-ID must be unique. (private)"
;; Low Level - clog-element
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
;; create-element ;;
;;;;;;;;;;;;;;;;;;
(defgeneric create-element (clog-obj html-tag &rest all-args &key content clog-type html-id
auto-place &allow-other-keys )
(:documentation "Create a new CLOG-element as child of CLOG-OBJ with any possible keywords.")
(:method (clog-obj html-tag &rest all-args &key (content "")
clog-type
(html-id (clog-connection:generate-id))
(auto-place t)
&allow-other-keys )
(let* ((extra-args (alexandria:remove-from-plist all-args :content :clog-type :html-id :auto-place))
(html (with-output-to-string (*standard-output*)
(format t "<~(~a~) " html-tag)
(loop for (key value) on extra-args by #'cddr
do (format t "~(~a~)=~s" key value))
(format t " id=~s>~A</~(~a~)>" html-id content html-tag)))
(clog-type (or clog-type
(let* ((class-name (intern (string-upcase (format nil "CLOG-~a" html-tag)) :clog)))
(when (find-class class-name nil)
class-name))
'clog-element)))
(create-child clog-obj html
:clog-type clog-type
:html-id html-id
:auto-place auto-place))))
;;;;;;;;;;;;;;;;;;
;; create-child ;;
;;;;;;;;;;;;;;;;;;

View file

@ -201,6 +201,7 @@ embedded in a native template application.)"
(clog-element class)
"CLOG-Element - Low Level Creation"
(create-element generic-function)
(create-child generic-function)
(attach-as-child generic-function)