;; -*- mode: common-lisp; package: lml2 -*-
;;
-;; $Id: htmlgen.lisp,v 1.12 2003/07/13 04:56:12 kevin Exp $
+;; $Id: htmlgen.lisp,v 1.13 2003/07/15 04:28:56 kevin Exp $
;;
;; copyright (c) 1986-2000 Franz Inc, Berkeley, CA
;; copyright (c) 2003 Kevin Rosenberg
;; argsp is true if this isn't a singleton tag (i.e. it has
;; a body) .. (:tag ...) or ((:tag ...) ...)
;; body is the body if any of the form
- ;;
+ ;;
(let (spec)
(if* (setq spec (html-process-special ent))
then ; do something different
(push `(,(html-process-macro ent) :unset) res)
nil
else ; some args
- (push `(,(html-process-macro ent) ,args
- ,(process-html-forms body env))
+ (push `(,(html-process-macro ent)
+ ,args
+ ,(process-html-forms body env))
res)
nil)))))
(prin1-safe-http-string ,(cadddr xx)))
res)
(pop xx) (pop xx)
+ elseif (eq :fformat (car xx))
+ then
+ ;; process :fformat
+ (unless (and (listp (cadr xx))
+ (>= (length (cadr xx)) 2))
+ (error ":fformat must be given a list"))
+ (push
+ `(write-string
+ ,(format nil " ~(~a~)=\"" (car (cadr xx)))
+ *html-stream*)
+ res)
+ (push
+ `(fformat *html-stream* ,(cadr (cadr xx))
+ ,@(cddr (cadr xx)))
+ res)
+ (push '(write-char #\" *html-stream*) res)
+ elseif (eq :optional (car xx))
+ then
+ (push
+ `(when ,(cadr (cadr xx))
+ (write-string
+ ,(format nil " ~(~a~)=\"" (car (cadr xx)))
+ *html-stream*)
+ (fformat *html-stream* "~A\""
+ ,(cadr (cadr xx))))
+ res)
else
(push `(write-string
(if (eq cmd :full)
(write-char (cadr form) stream)
(error ":write-char must be given an argument")))))
+
+;; fast formatter
+(def-special-html :fformat
+ (named-function html-write-char-function
+ (lambda (ent args argsp body)
+ (declare (ignore ent args argsp))
+ `(progn ,@(mapcar #'(lambda (bod)
+ `(progn
+ (format *html-stream* " ~(~A~)=\"" (car ,bod))
+ (apply #'format *html-stream* (cdr ,bod))
+ (write-char #\" *html-stream*)))
+ body))))
+
+ (named-function html-write-char-print-function
+ (lambda (ent cmd args form subst unknown stream)
+ (declare (ignore args ent unknown subst))
+ (assert (eql 2 (length form)))
+ (if (eq cmd :full)
+ (progn
+ (format stream " ~(~A~)=\"" (car form))
+ (apply #'format stream (cdr form))
+ (write-char #\" stream))
+ (error ":fformat must be given an argument")))))
+
;;;; Author: Kevin M. Rosenberg\r
;;;; Date Started: June 2002\r
;;;;\r
-;;;; $Id: utils.lisp,v 1.3 2003/07/12 17:54:05 kevin Exp $\r
+;;;; $Id: utils.lisp,v 1.4 2003/07/15 04:28:56 kevin Exp $\r
;;;;\r
;;;; This file, part of LML2, is copyrighted and open-source software.\r
;;;; Rights of modification and redistribution are in the LICENSE file.\r
#-(or allegro clisp cmu scl sbcl cormanlisp lispworks lucid mcl) (truename "."))\r
\r
\r
+\r
+(defun fformat (&rest args)\r
+ (declare (dynamic-extent args))\r
+ (apply #'format args))\r