Changed ps-inline to take a form instead of an implicit progn as a parameter; gave...
authorVladimir Sedach <vsedach@gmail.com>
Tue, 16 Oct 2007 22:04:45 +0000 (22:04 +0000)
committerVladimir Sedach <vsedach@gmail.com>
Tue, 16 Oct 2007 22:04:45 +0000 (22:04 +0000)
The optional arguments bind *js-quote-char* to make it more convenient
to use the two functions with different html generation macros (which
may use single or double quotes to delimit attribute values).

docs/reference.lisp
src/compilation-interface.lisp
t/ps-tests.lisp
t/reference-tests.lisp

index 9405532..aeb61dc 100644 (file)
@@ -926,7 +926,7 @@ a-variable  => aVariable
 (document.write
   (ps-html ((:a :href "#"
                 :onclick (lisp (ps-inline (transport)))) "link")))
-  => document.write('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')
+  => document.write('<a href=\"#\" onclick=\"' + 'javascript:transport()' + '\">link</a>')
 
 ;;; Forms may be used in attribute lists to conditionally generate
 ;;; the next attribute. In this example the textarea is sometimes disabled.
index eac01eb..ec35faa 100644 (file)
@@ -16,12 +16,13 @@ is output to the OUTPUT-STREAM stream."
 Body is evaluated."
   (compile-script `(progn ,@body)))
 
-(defun ps-inline* (form)
-  (concatenate 'string
-               "javascript:"
-               (remove #\Newline
-                       (parenscript-print (compile-parenscript-form form :expecting :statement))
-                       :from-end t)))
+(defun ps-inline* (form &optional (quote-char #\"))
+  (let ((*js-quote-char* quote-char))
+    (concatenate 'string
+                 "javascript:"
+                 (remove #\Newline
+                         (parenscript-print (compile-parenscript-form form :expecting :statement))
+                         :from-end t))))
 
-(defmacro ps-inline (&body body)
-  `(ps-inline* '(progn ,@body)))
+(defmacro ps-inline (form &optional (quote-char #\"))
+  `(ps-inline* ',form ,quote-char))
index 61bf3eb..d31f801 100644 (file)
@@ -395,7 +395,7 @@ x = 2 + sideEffect() + x + 5;")
                      :onclick (lisp (ps-inline (transport))))
                  img))
        img))
-  "document.write(LINKORNOT == 1 ? '<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">' + img + '</a>' : img)")
+  "document.write(LINKORNOT == 1 ? '<a href=\"#\" onclick=\"' + 'javascript:transport()' + '\">' + img + '</a>' : img)")
 
 (test-ps-js negate-number-literal ;; ok, this was broken and fixed before, but no one bothered to add the test!
   (- 1)
index 901de02..4aea054 100644 (file)
@@ -484,7 +484,7 @@ _js2.style.left = _js1;")
   (document.write
   (ps-html ((:a :href "#"
                 :onclick (lisp (ps-inline (transport)))) "link")))
-  "document.write('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')")
+  "document.write('<a href=\"#\" onclick=\"' + 'javascript:transport()' + '\">link</a>')")
 
 (test-ps-js the-html-generator-4
   (let ((disabled nil)