From: Vladimir Sedach Date: Thu, 22 Jan 2009 05:14:15 +0000 (-0700) Subject: Made the ps-html macros generate self-closing tags. X-Git-Url: http://git.hcoop.net/clinton/parenscript.git/commitdiff_plain/11a0e241697421d797e229ef632aef0a4b0d326a Made the ps-html macros generate self-closing tags. --- diff --git a/src/js-dom-symbol-exports.lisp b/src/js-dom-symbol-exports.lisp index 4850b14..cf2b50d 100644 --- a/src/js-dom-symbol-exports.lisp +++ b/src/js-dom-symbol-exports.lisp @@ -49,6 +49,7 @@ #:elements #:.get-elements-by-class-name #:.get-element-by-id + #:onselectstart )) (defpackage "PS-PROTOTYPE-LIB-SYMBOLS" diff --git a/src/lib/ps-html.lisp b/src/lib/ps-html.lisp index 84ca2db..55eb02e 100644 --- a/src/lib/ps-html.lisp +++ b/src/lib/ps-html.lisp @@ -1,5 +1,7 @@ (in-package :parenscript) +(defvar *self-closing-tags-p* t) + (defun concat-constant-strings (str-list) (reverse (reduce (lambda (optimized-list next-obj) (if (and (or (numberp next-obj) (stringp next-obj)) (stringp (car optimized-list))) @@ -36,9 +38,11 @@ (push (format nil " ~A=\"" attr-name) r) (push attr-val r) (push "\"" r)))) - (push ">" r) - (map nil #'process-form (cdr form)) - (push (format nil "" (caar form)) r)) + (if (or (cdr form) (not *self-closing-tags-p*)) + (progn (push ">" r) + (map nil #'process-form (cdr form)) + (push (format nil "" (caar form)) r)) + (push "/>" r))) (t (push form r))))) (map nil #'process-form forms) (concat-constant-strings (reverse r))))) @@ -65,10 +69,11 @@ (push "\"" r) (process-attributes (cddr attrs)))))) (process-attributes (cdr form)) - (push ">" r) - (when content - (map nil #'process-form content)))) - (push (format nil "" (car form)) r)) + (if (or content (not *self-closing-tags-p*)) + (progn (push ">" r) + (when content (map nil #'process-form content)) + (push (format nil "" (car form)) r)) + (push "/>" r))))) (t (push form r))))) (map nil #'process-form forms) (concat-constant-strings (reverse r))))) diff --git a/src/package.lisp b/src/package.lisp index 179a715..983c877 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -145,6 +145,7 @@ ;; v v v STUFF WE SHOULD PROBABLY MOVE TO OTHER LIBS v v v ;; html generator for javascript + #:*self-closing-tags-p* #:ps-html #:who-ps-html