diff options
author | colin <colin@cicadas.surf> | 2024-06-22 14:53:18 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-06-22 14:53:18 -0700 |
commit | b6d59c01066ab2315e84fe7eb5659e376e56de1b (patch) | |
tree | d42888fad2e5caa5716ebde139e46d2b57258157 | |
parent | 4602591267732858e7125fdfabb781d8f23d6d2f (diff) |
Add: parenscript dep; Fix: html elem render; Fix: <elem-replace>
-rw-r--r-- | hypnotisml.asd | 2 | ||||
-rw-r--r-- | src/hypnotisml.lisp | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/hypnotisml.asd b/hypnotisml.asd index 28fb47c..53be346 100644 --- a/hypnotisml.asd +++ b/hypnotisml.asd @@ -7,6 +7,6 @@ :version "0.0.1" :pathname "src/" :serial t - :depends-on (#:def #:alexandria) + :depends-on (#:def #:alexandria #:parenscript) :components ((:file "package") (:file "hypnotisml"))) diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp index 5b0a7dd..d39844a 100644 --- a/src/hypnotisml.lisp +++ b/src/hypnotisml.lisp @@ -81,6 +81,9 @@ (children :type node-list) :documentation "The base class for all UI elements.") +(defun elem-query-selector (elem) + (format nil "[data-hypno-id=~s]" (elem-id elemp))) + (defmethod print-object ((object elem) stream) (indent stream) @@ -168,8 +171,7 @@ (format t " ~{~a=~s~^ ~}" (attribs-list attributes))) (when (and style (styles-list style)) - (when attributes (write-char #\space)) - (write-string "style=") + (write-string " style=") (write-char #\") (format t "~{~a:~a;~}" (styles-list style)) (write-char #\")) @@ -412,7 +414,7 @@ ;;; Parenscript (ps:defpsmacro <elem> (elem) - `(ps:@ document (get-element-by-id (ps:lisp (elem-id ,elem))))) + `(ps:chain document (query-selector (ps:lisp (elem-query-selector ,elem))))) (ps:defpsmacro <replace-elem> (elem innerhtml) (let ((template (ps:ps-gensym))) |