Made who-ps-html handle multiple html forms correctly (ie - things like (:ul (:li...
authorVladimir Sedach <vsedach@gmail.com>
Fri, 6 Feb 2009 02:02:03 +0000 (19:02 -0700)
committerVladimir Sedach <vsedach@gmail.com>
Fri, 6 Feb 2009 02:02:03 +0000 (19:02 -0700)
src/lib/ps-html.lisp
t/ps-tests.lisp

index 55eb02e..b9dc51f 100644 (file)
                      ((atom form) (push form r))
                      ((and (consp form) (keywordp (car form)))
                       (push (format nil "<~A" (car form)) r)
-                      (let (content)
-                        (labels ((process-attributes (attrs)
-                                   (cond ((null attrs) )
-                                         ((= 1 (length attrs)) (setf content attrs))
-                                         ((consp (car attrs))
-                                          (push `(if ,(first attrs)
-                                                     (concat-string ,(format nil " ~A=\"" (second attrs)) ,(third attrs) "\"")
-                                                     "")
-                                                r)
-                                          (process-attributes (cdddr attrs)))
-                                         (t (push (format nil " ~A=\"" (first attrs)) r)
-                                            (push (second attrs) r)
-                                            (push "\"" r)
-                                            (process-attributes (cddr attrs))))))
-                          (process-attributes (cdr form))
+                      (labels ((process-attributes (el-body)
+                                 (when el-body
+                                   (if (or (consp (car el-body)) (= 1 (length el-body)))
+                                       el-body
+                                       (progn (push (format nil " ~A=\"" (car el-body)) r)
+                                              (push (cadr el-body) r)
+                                              (push "\"" r)
+                                              (process-attributes (cddr el-body)))))))
+                        (let ((content (process-attributes (cdr form))))
                           (if (or content (not *self-closing-tags-p*))
                               (progn (push ">" r)
                                      (when content (map nil #'process-form content))
index 710b49b..4663c44 100644 (file)
@@ -691,3 +691,11 @@ try {
 (test-ps-js slot-value-lambda
   (slot-value (lambda ()) 'prototype)
   "(function () { }).prototype")
+
+(test-ps-js who-html1
+  (who-ps-html (:span :class "ticker-symbol"
+                      :ticker-symbol symbol
+                      (:a :href "http://foo.com"
+                          symbol)
+                      (:span :class "ticker-symbol-popup")))
+  "'<SPAN CLASS=\"ticker-symbol\" TICKER-SYMBOL=\"' + symbol + '\"><A HREF=\"http://foo.com\">' + symbol + '</A><SPAN CLASS=\"ticker-symbol-popup\"/></SPAN>'")