Discussion:
should cl-who::*html-mode* be a compile time flag?
Mac Chan
2007-03-29 18:14:04 UTC
Permalink
Hi,

The following code

(defparameter *checked* nil)

(with-html-output (#:out nil :prologue nil :indent nil)
(:input :type "checkbox" :checked *checked*))

will get expanded to

=>

(let ((#:out #:out))
(progn
nil
(write-string "<input type=\"checkbox\"" #:out)
(let ((#:g2546 *checked*))
(cond ((null #:g2546))
((and (eq #:g2546 t) (eq cl-who::*html-mode* :xml))
(progn (write-string " checked=\"checked\"" #:out)))
((and (eq #:g2546 t) (eq cl-who::*html-mode* :sgml))
(progn (write-string " checked" #:out)))
(t
(progn
(write-string " checked=\"" #:out)
(princ #:g2546 #:out)
(write-string "\"" #:out)))))
(write-string " />" #:out)))


My question is, should the macro generate code based on the value of
*html-mode* at compile/load time instead of runtime?

If there are a lot of attributes the generated code will be bloated
and I can't imagine a situation where you want to apply the same
cl-who syntax tree with different *html-mode* at runtime.

If there's a rational behind this I'd like to learn about it.

Thanks,
-- Mac
Edi Weitz
2007-03-30 07:52:05 UTC
Permalink
Post by Mac Chan
The following code
(defparameter *checked* nil)
(with-html-output (#:out nil :prologue nil :indent nil)
(:input :type "checkbox" :checked *checked*))
will get expanded to
=>
(let ((#:out #:out))
(progn
nil
(write-string "<input type=\"checkbox\"" #:out)
(let ((#:g2546 *checked*))
(cond ((null #:g2546))
((and (eq #:g2546 t) (eq cl-who::*html-mode* :xml))
(progn (write-string " checked=\"checked\"" #:out)))
((and (eq #:g2546 t) (eq cl-who::*html-mode* :sgml))
(progn (write-string " checked" #:out)))
(t
(progn
(write-string " checked=\"" #:out)
(princ #:g2546 #:out)
(write-string "\"" #:out)))))
(write-string " />" #:out)))
My question is, should the macro generate code based on the value of
*html-mode* at compile/load time instead of runtime?
If there are a lot of attributes the generated code will be bloated
and I can't imagine a situation where you want to apply the same
cl-who syntax tree with different *html-mode* at runtime.
If there's a rational behind this I'd like to learn about it.
I don't remember the details, but I guess this was just an oversight
of Stefan when he sent the HTML-MODE patch in 2005. Feel free to send
a patch to change this behaviour if you think it's worth it.

Thanks,
Edi.
Mac Chan
2007-03-30 18:36:30 UTC
Permalink
Post by Edi Weitz
I don't remember the details, but I guess this was just an oversight
of Stefan when he sent the HTML-MODE patch in 2005. Feel free to send
a patch to change this behaviour if you think it's worth it.
Sure, attached is a patch for this and also remove extra newlines if
no prologue is specified.

(I sometime log the generated html and the extra newline make the
hunchentoot log very hard to read)

Too bad http://common-lisp.net/~loliveira/ediware/ didn't track as far
back as 2005.
But in this case the change is trivial, otherwise the revision history
will be very helpful.

Thanks,
-- Mac
Edi Weitz
2007-03-31 10:53:41 UTC
Permalink
Post by Mac Chan
Sure, attached is a patch for this and also remove extra newlines if
no prologue is specified.
Thanks. I'm on my way to Cambridge for the ILC now, so I probably
won't be able to update this before the end of next week.
Post by Mac Chan
But in this case the change is trivial, otherwise the revision
history will be very helpful.
You could bug Pierre Thierry to add CL-WHO to his list:

http://arcanes.fr.eu.org/~pierre/2007/02/weitz/

Cheers,
Edi.
Edi Weitz
2007-04-05 07:01:35 UTC
Permalink
Post by Mac Chan
Sure, attached is a patch for this and also remove extra newlines if
no prologue is specified.
Thanks. I've released a new version which incorporates your patches.
Loading...