Ron Garret
2010-01-23 17:51:36 UTC
Is there a Right Way to use CL-WHO to generate HTML at run time? For example, suppose I want to do something like this:
(defun make-table (l)
`(:table ,@(mapcar (lambda (row) `(:tr ,@(mapcar (lambda (cell) `(:td (str ,cell)))
row)))
l)))
(cl-who:with-html-output-to-string (*standard-output* nil :prologue t)
... (make-table l) ...)
This doesn't work because CL-WHO normally does all its work at compile time, but L is not known until run time. I can hack this using a macro that calls EVAL, or by hacking the CL-WHO code to add another specially handled symbol, but before diving into that rabbit hole I thought I'd ask if there was already a way of doing this that I've overlooked.
Thanks,
rg
(defun make-table (l)
`(:table ,@(mapcar (lambda (row) `(:tr ,@(mapcar (lambda (cell) `(:td (str ,cell)))
row)))
l)))
(cl-who:with-html-output-to-string (*standard-output* nil :prologue t)
... (make-table l) ...)
This doesn't work because CL-WHO normally does all its work at compile time, but L is not known until run time. I can hack this using a macro that calls EVAL, or by hacking the CL-WHO code to add another specially handled symbol, but before diving into that rabbit hole I thought I'd ask if there was already a way of doing this that I've overlooked.
Thanks,
rg