summaryrefslogtreecommitdiff
path: root/src/hypnotisml.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hypnotisml.lisp')
-rw-r--r--src/hypnotisml.lisp16
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)