Function: EMIT-PRINC-ATTRIBUTES

Documentation

Assuming attributes is a list of (name1 value1 name2 value2 ...), emit the code necessary to print them at runtime. If VALUE is a list every element will be concatenated separated by a space to form the final string value of the attribute. If the value of any of the attributes is NIL it will be ignored. If a value is the symbol T the name of the attribute will be used as the value.

Source

(defun emit-princ-attributes (attributes)
  "Assuming attributes is a list of (name1 value1 name2 value2 ...), emit
the code necessary to print them at runtime. If VALUE is a
list every element will be concatenated separated by a space to
form the final string value of the attribute.

If the value of any of the attributes is NIL it will be ignored.

If a value is the symbol T the name of the attribute will be used
as the value."
  (iter (while attributes)
        (for key = (pop attributes))
        (if (runtime-attribute-list-reference-p key)
            (emit-code `(iter (for (name value) :on ,(ralr-form key) :by #'cddr)
                              (unless (stringp name)
                                (setf name (string-downcase (string name))))
                              (emit-attribute name value)))
            (let ((value (pop attributes)))
              (cond
                ((eql t value)
                 ;; according to xhtml thoses attributes which in html are
                 ;; specified without a value should just use the attribute
                 ;; name as the xhtml value
                 (emit-princ " " key "=\"" key "\""))
                ((eql nil value) nil)
                ((yaclml-constant-p value)
                 (progn
                   (emit-princ " " key "=\"")
                   (emit-html value)
                   (emit-princ "\"")))
                (t
                 (if (and (consp value)
                          (eql 'cl:concatenate (first value))
                          (consp (cdr value))
                          (eql 'cl:string (second value)))
                     ;; a call to concatenate can be dealt with specially
                     (progn
                       (emit-princ " " key "=\"")
                       (dolist (val (cddr value))
                         (emit-princ val)))
                     (emit-princ-attribute key value)))))))
  %yaclml-code%)
Source Context