diff options
author | colin <colin@cicadas.surf> | 2024-06-29 07:56:00 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-06-29 07:56:00 -0700 |
commit | 1ca58017958cac2028d692a2889e97daa794df07 (patch) | |
tree | cfd0d96c11833a226d9f768408170b99cbcc3081 | |
parent | b7da7a19e98b80fdf044d3e910d866e464653b85 (diff) |
Fix: element id query selector string; Change names of ps macros
-rw-r--r-- | src/hypnotisml.lisp | 10 | ||||
-rw-r--r-- | src/package.lisp | 6 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp index b70a8a8..13e4bab 100644 --- a/src/hypnotisml.lisp +++ b/src/hypnotisml.lisp @@ -105,7 +105,7 @@ (defun elem-query-selector (elem) "Returns a CSS query selector string for the ELEM. ELEMs can be uniquely quried in the dom by passing string to .querySelector()" - (format nil "[data-hypno-id=~s]" (elem-id elem))) + (format nil "[data-hypno-id='~a']" (elem-id elem))) (defun style (elem property) (a:when-let (style (elem-style elem)) @@ -600,13 +600,15 @@ E.g. :1/2, :1, :3/4" ,@contents)))) -;;; Parenscript +;;; PARENSCRIPT -(ps:defpsmacro $$ (elem) +(ps:defpsmacro js.elem (elem) `(ps:chain document (query-selector (ps:lisp (elem-query-selector ,elem))))) -(ps:defpsmacro $$replace (elem innerhtml) +(ps:defpsmacro js.replace (elem innerhtml) (let ((template (ps:ps-gensym))) `(let ((,template (ps:chain document (create-element "template")))) (setf (ps:@ ,template inner-h-t-m-l) ,innerhtml) (ps:chain ($$ ,elem) (replace-with (ps:@ ,template content)))))) + + diff --git a/src/package.lisp b/src/package.lisp index 5743aa3..36d975b 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -169,9 +169,9 @@ #:$hcenter) ;; parenscript macros - ;; (:export - ;; #:$$ - ;; #:$$replace) + (:export + #:js.elem + #:js.replace) ;; transforms and structure editing (:export |