From ron at flownet.com Sat Jan 23 17:51:36 2010 From: ron at flownet.com (Ron Garret) Date: Sat, 23 Jan 2010 09:51:36 -0800 Subject: [cl-who-devel] Runtime HTML generation Message-ID: <4954AABF-F013-471A-85CB-2D705D414C9E@flownet.com> 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 From joubert.nel at infiniteimprobability.com Sat Jan 23 19:45:33 2010 From: joubert.nel at infiniteimprobability.com (Joubert Nel) Date: Sat, 23 Jan 2010 14:45:33 -0500 Subject: [cl-who-devel] Runtime HTML generation In-Reply-To: <4954AABF-F013-471A-85CB-2D705D414C9E@flownet.com> References: <4954AABF-F013-471A-85CB-2D705D414C9E@flownet.com> Message-ID: <9464890E-EC17-4F4D-A59B-824748139835@infiniteimprobability.com> Hi Ron, You can use the with-html-output-to-string function to generate HTML at run-time. Using it in a macro, you can then do data-driven HTML construction using mapcar, loop, etc. Joubert On Jan 23, 2010, at 12:51 PM, Ron Garret wrote: > 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 > > > _______________________________________________ > cl-who-devel site list > cl-who-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-who-devel From stassats at gmail.com Sat Jan 23 19:51:15 2010 From: stassats at gmail.com (Stas Boukarev) Date: Sat, 23 Jan 2010 22:51:15 +0300 Subject: [cl-who-devel] Runtime HTML generation In-Reply-To: <9464890E-EC17-4F4D-A59B-824748139835@infiniteimprobability.com> (Joubert Nel's message of "Sat, 23 Jan 2010 14:45:33 -0500") References: <4954AABF-F013-471A-85CB-2D705D414C9E@flownet.com> <9464890E-EC17-4F4D-A59B-824748139835@infiniteimprobability.com> Message-ID: <87d4104n2k.fsf@gmail.com> Joubert Nel writes: > Hi Ron, > > You can use the with-html-output-to-string function to generate HTML at run-time. > Using it in a macro, you can then do data-driven HTML construction using mapcar, loop, etc. with-html-output-to-string is a macro. -- With Best Regards, Stas. From ron at flownet.com Sat Jan 23 20:20:22 2010 From: ron at flownet.com (Ron Garret) Date: Sat, 23 Jan 2010 12:20:22 -0800 Subject: [cl-who-devel] Runtime HTML generation In-Reply-To: <9464890E-EC17-4F4D-A59B-824748139835@infiniteimprobability.com> References: <4954AABF-F013-471A-85CB-2D705D414C9E@flownet.com> <9464890E-EC17-4F4D-A59B-824748139835@infiniteimprobability.com> Message-ID: <57419600-B187-469D-9A2C-EFD5743D083B@flownet.com> No, that won't work. with-html-output-to-string is a macro, not a function. It does its work at macroexpansion time, not run-time. (You might want to re-read my original message.) rg On Jan 23, 2010, at 11:45 AM, Joubert Nel wrote: > Hi Ron, > > You can use the with-html-output-to-string function to generate HTML at run-time. > Using it in a macro, you can then do data-driven HTML construction using mapcar, loop, etc. > > Joubert > > > On Jan 23, 2010, at 12:51 PM, Ron Garret wrote: > >> 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 >> >> >> _______________________________________________ >> cl-who-devel site list >> cl-who-devel at common-lisp.net >> http://common-lisp.net/mailman/listinfo/cl-who-devel > > > > > _______________________________________________ > cl-who-devel site list > cl-who-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-who-devel From J.k.cunningham at comcast.net Sat Jan 23 20:56:42 2010 From: J.k.cunningham at comcast.net (J. K. Cunningham) Date: Sat, 23 Jan 2010 12:56:42 -0800 Subject: [cl-who-devel] Runtime HTML generation In-Reply-To: <57419600-B187-469D-9A2C-EFD5743D083B@flownet.com> References: <4954AABF-F013-471A-85CB-2D705D414C9E@flownet.com> <9464890E-EC17-4F4D-A59B-824748139835@infiniteimprobability.com> <57419600-B187-469D-9A2C-EFD5743D083B@flownet.com> Message-ID: <1264280202.16155.7.camel@golum.olympus.net> On Sat, 2010-01-23 at 12:20 -0800, Ron Garret wrote: > No, that won't work. with-html-output-to-string is a macro, not a function. It does its work at macroexpansion time, not run-time. (You might want to re-read my original message.) > This works - I just put an example up on a website to try it - code is there: http://jandmworks.com/test.html (defun make-table (l) (with-html-output (*standard-output*) (:table :border 1 (mapcar (lambda (row) (htm (:tr (mapcar (lambda (cell) (htm (:td (str cell)))) row)))) l)))) The list I'm passing it could have come from anywhere - a file, a posted response, etc. Jeff > rg > > On Jan 23, 2010, at 11:45 AM, Joubert Nel wrote: > > > Hi Ron, > > > > You can use the with-html-output-to-string function to generate HTML at run-time. > > Using it in a macro, you can then do data-driven HTML construction using mapcar, loop, etc. > > > > Joubert > > > > > > On Jan 23, 2010, at 12:51 PM, Ron Garret wrote: > > > >> 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 > >> > >> > >> _______________________________________________ > >> cl-who-devel site list > >> cl-who-devel at common-lisp.net > >> http://common-lisp.net/mailman/listinfo/cl-who-devel > > > > > > > > > > _______________________________________________ > > cl-who-devel site list > > cl-who-devel at common-lisp.net > > http://common-lisp.net/mailman/listinfo/cl-who-devel > > > _______________________________________________ > cl-who-devel site list > cl-who-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-who-devel From ron at flownet.com Sat Jan 23 23:11:00 2010 From: ron at flownet.com (Ron Garret) Date: Sat, 23 Jan 2010 15:11:00 -0800 Subject: [cl-who-devel] Runtime HTML generation In-Reply-To: <1264280202.16155.7.camel@golum.olympus.net> References: <4954AABF-F013-471A-85CB-2D705D414C9E@flownet.com> <9464890E-EC17-4F4D-A59B-824748139835@infiniteimprobability.com> <57419600-B187-469D-9A2C-EFD5743D083B@flownet.com> <1264280202.16155.7.camel@golum.olympus.net> Message-ID: Ah. I think I get it now. Thanks! rg On Jan 23, 2010, at 12:56 PM, J. K. Cunningham wrote: > On Sat, 2010-01-23 at 12:20 -0800, Ron Garret wrote: >> No, that won't work. with-html-output-to-string is a macro, not a function. It does its work at macroexpansion time, not run-time. (You might want to re-read my original message.) >> > > This works - I just put an example up on a website to try it - code is > there: > > http://jandmworks.com/test.html > > (defun make-table (l) > (with-html-output (*standard-output*) > (:table :border 1 (mapcar (lambda (row) (htm > (:tr (mapcar (lambda (cell) > (htm (:td (str cell)))) row)))) l)))) > > The list I'm passing it could have come from anywhere - a file, a posted response, etc. > > Jeff > > > >> rg >> >> On Jan 23, 2010, at 11:45 AM, Joubert Nel wrote: >> >>> Hi Ron, >>> >>> You can use the with-html-output-to-string function to generate HTML at run-time. >>> Using it in a macro, you can then do data-driven HTML construction using mapcar, loop, etc. >>> >>> Joubert >>> >>> >>> On Jan 23, 2010, at 12:51 PM, Ron Garret wrote: >>> >>>> 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 >>>> >>>> >>>> _______________________________________________ >>>> cl-who-devel site list >>>> cl-who-devel at common-lisp.net >>>> http://common-lisp.net/mailman/listinfo/cl-who-devel >>> >>> >>> >>> >>> _______________________________________________ >>> cl-who-devel site list >>> cl-who-devel at common-lisp.net >>> http://common-lisp.net/mailman/listinfo/cl-who-devel >> >> >> _______________________________________________ >> cl-who-devel site list >> cl-who-devel at common-lisp.net >> http://common-lisp.net/mailman/listinfo/cl-who-devel > > > _______________________________________________ > cl-who-devel site list > cl-who-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-who-devel