Add DO-HTML-COND
authorMatthew Mondor <mmondor@pulsar-zone.net>
Sat, 27 Aug 2011 03:45:50 +0000 (03:45 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Sat, 27 Aug 2011 03:45:50 +0000 (03:45 +0000)
mmsoftware/cl/server/html.lisp

index 9d93824..6519cd6 100644 (file)
@@ -1,4 +1,4 @@
-;;;; $Id: html.lisp,v 1.5 2011/08/27 02:30:34 mmondor Exp $
+;;;; $Id: html.lisp,v 1.6 2011/08/27 03:45:50 mmondor Exp $
 
 #|
 
@@ -45,12 +45,13 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
           #:do-html-when
           #:do-html-unless
           #:do-html-if
+          #:do-html-cond
           #:html-escape))
 
 (in-package :html)
 
 (defparameter *rcsid*
-  "$Id: html.lisp,v 1.5 2011/08/27 02:30:34 mmondor Exp $")
+  "$Id: html.lisp,v 1.6 2011/08/27 03:45:50 mmondor Exp $")
 
 
 (defparameter *html-mode* :xhtml
@@ -281,6 +282,15 @@ implicit DO-HTML NIL.  For use within DO-HTML forms."
        (do-html nil
         ,else)))
 
+(defmacro do-html-cond (&body clauses)
+  `(cond
+     ,@(mapcar #'(lambda (clause)
+                  (destructuring-bind (condition &body form) clause
+                    `(,condition
+                      (do-html nil
+                        ,@form))))
+              clauses)))
+
 (defun html-escape (string)
   "Returns a fresh copy of STRING which is safe for use within HTML.
 Note that for simplicity, efficiency and to allow nested DO-HTML forms,