Here is some food for thought:
(with-output-to-string (s) (cl-who:with-html-output (s) (dotimes (i 10) (cl-who:htm (:p "hello")))))
-Hans
On Fri, Dec 23, 2011 at 5:46 PM, Tyler Smith tyler.smith@mail.mcgill.ca wrote:
Thank you!
I didn't realize that with-html-output was returning a string, I thought it was emitting the html to the output as a side effect. In retrospect, that's silly.
The following works, although it looks a little unwieldy. Any suggestions for improvement are welcome. Otherwise, thanks for your help and for all your code.
Cheers,
Tyler
(define-easy-handler (tyler :uri "/tyler") () (multiple-value-bind (records fields) (select [genus] [species] :from "specimens") (loop for rec in records collect (loop for label in fields for val in rec collect (with-html-output-to-string (*standard-output*) (:dt :class label (str label)) (:dd :class label (str val))) into inner-output finally (return (format nil "~{~a~&~}" inner-output))) into outer-output finally (return (format nil "~{~a~&~}" outer-output)))))
On Fri, Dec 23, 2011 at 3:05 AM, Edi Weitz edi@agharta.de wrote:
Your loop doesn't return anything, does it?
On Thu, Dec 22, 2011 at 11:51 PM, Tyler Smith tyler.smith@mail.mcgill.ca wrote:
Hi,
I'm trying to set up a simple sql-based website using cl-who, cl-sql and hunchentoot. I've got the basic cl-sql and cl-who parts working, but I'm having a trouble serving the pages with hunchentoot.
The following works as expected:
(ql:quickload :hunchentoot) (use-package :hunchentoot)
(setf my-acceptor (start (make-instance 'hunchentoot:easy-acceptor :port 4242)))
(define-easy-handler (tyler :uri "/tyler") () (with-html-output (*standard-output*) (:ul (:li "hi there again"))))
After this, if I open localhost:4242/tyler in a browser I see my unordered list. However, with this:
(define-easy-handler (tyler :uri "/tyler") () (multiple-value-bind (records fields) (select [genus] [species] :from "specimens") (loop for rec in records do (loop for label in fields for val in rec do (with-html-output (*standard-output*) (:dt :class label (str label)) (:dd :class label (str val)))))))
When I browse to localhost:4242/tyler nothing appears in the browser, instead the html is printed in the REPL. If I evaluate just the (M-V-B ...) form without the enclosing (D-E-H ...) it outputs the html to the REPL as I expect.
I have been following the examples in the hunchentoot docs, but I'm stumped as to why this doesn't work. What have I missed?
Thanks,
Tyler
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel