diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hypnotisml.lisp | 16 | ||||
-rw-r--r-- | src/package.lisp | 2 |
2 files changed, 14 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) diff --git a/src/package.lisp b/src/package.lisp index 5064b6c..64d3d87 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -156,6 +156,8 @@ #:@ #:@= #:@~ + #:@!= + #:@!~ #:@? #:$ #:$= |