diff options
author | colin <colin@cicadas.surf> | 2024-11-24 09:28:14 -0800 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-11-24 09:28:14 -0800 |
commit | 9e81bf6a8fa8262566a33797aa9dfd51f40e80dc (patch) | |
tree | db90bf6ad2128e48bdd292a0dbc0ee9c3cbfe0a6 /src/hypnotisml.lisp | |
parent | 8040abe92f2c8097aa40a609a6fac2ef5e22a2d3 (diff) |
Alter ATTRIBS debug printing; add more attribs updaters
Diffstat (limited to 'src/hypnotisml.lisp')
-rw-r--r-- | src/hypnotisml.lisp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp index 544f195..7a71fad 100644 --- a/src/hypnotisml.lisp +++ b/src/hypnotisml.lisp @@ -60,7 +60,7 @@ (list nil :type keyword-plist)) (defmethod print-object ((ob attribs) stream) - (format stream "~{~a=~s~^ ~}" (attribs-list ob))) + (format stream "{~{~a=~s~^ ~}}" (attribs-list ob))) (def:class node () (parent :type (or null elem)) @@ -227,15 +227,23 @@ Returns ELEM." (make-attribs :list plist))) elem) +(defun @!= (elem attrs) + "Like @= but attrs is an ATTRIBS instance." + (apply #'@= elem (attribs-list attrs))) + +(defun @!~ (elem attrs) + "Like @~ but attrs is an ATTRIBS instance." + (apply #'@~ elem (attribs-list attrs))) + (defun @~ (elem &rest plist) "Just like @= except an attribute WILL NOT be updated if it is already present in the element." (check-type plist keyword-plist) (a:if-let (attribs (elem-attributes elem)) (loop - :for (prop val) :on plist :by #'cddr - :when (and val (not (getf (attribs-list attribs) prop))) - :do (setf (getf (attribs-list attribs) prop) val)) + :for (prop val) :on plist :by #'cddr + :when (and val (not (getf (attribs-list attribs) prop))) + :do (setf (getf (attribs-list attribs) prop) val)) (setf (elem-attributes elem) (make-attribs :list plist))) elem) |