Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cl-who:with-html-output-to-string question

87 views
Skip to first unread message

Slobodan Blazeski

unread,
Dec 10, 2007, 1:23:21 PM12/10/07
to
This questionsupposed to go to cl-who devel but confirmation email for
confirmation of subscribtion of the cl-who mail list isn't coming in
my inbox.

I'm trying to produce this output
"<texarea name='NAME' type='TYPE'>value</texarea>"
With this everything is ok:
(cl-who:with-html-output-to-string (s)
(:texarea :name 'name :type 'type "value"))
"<texarea name='NAME' type='TYPE'>value</texarea>"

but why doesn't below work (value is missing)
(cl-who:with-html-output-to-string (s)
(:texarea :name 'name :type 'type 'value))
"<texarea name='NAME' type='TYPE'></texarea>"

or this
(cl-who:with-html-output-to-string (s)
(:texarea :name 'name :type 'type (princ-to-string 'value)))
or this
(let ((val "value"))
(cl-who:with-html-output-to-string (s)
(:texarea :name 'name :type 'type val)))
"<texarea name='NAME' type='TYPE'></texarea>"


How to write a function like this
(defun test (name type value)
(cl-who:with-html-output-to-string (s)
(:texarea :name name :type type value)))

that will render the value
(test 'name 'type 'value)
"<texarea name='NAME' type='TYPE'></texarea>"
(test 'name 'type "value")
"<texarea name='NAME' type='TYPE'></texarea>"

thanks
Slobodan


Sohail Somani

unread,
Dec 10, 2007, 1:59:44 PM12/10/07
to
On Mon, 10 Dec 2007 10:23:21 -0800, Slobodan Blazeski wrote:

> but why doesn't below work (value is missing)
> (cl-who:with-html-output-to-string (s)
> (:texarea :name 'name :type 'type 'value))
> "<texarea name='NAME' type='TYPE'></texarea>"
>
> or this
> (cl-who:with-html-output-to-string (s)
> (:texarea :name 'name :type 'type (princ-to-string
'value)))
> or this
> (let ((val "value"))
> (cl-who:with-html-output-to-string (s)
> (:texarea :name 'name :type 'type val)))
> "<texarea name='NAME' type='TYPE'></texarea>"

I think you have to change the use to something like:

(:textarea :name 'name :type 'type (cl-who:str (princ-to-string 'value)))

--
Sohail Somani
http://uint32t.blogspot.com

Maciej Katafiasz

unread,
Dec 10, 2007, 2:24:07 PM12/10/07
to
Den Mon, 10 Dec 2007 18:59:44 +0000 skrev Sohail Somani:

>> (let ((val "value"))
>> (cl-who:with-html-output-to-string (s)
>> (:texarea :name 'name :type 'type val)))
>> "<texarea name='NAME' type='TYPE'></texarea>"
>
> I think you have to change the use to something like:
>
> (:textarea :name 'name :type 'type (cl-who:str (princ-to-string
> 'value)))

PRINC-TO-STRING is unnecessary, cl-who:str knows how to deal with symbols
already (though symbols in general are printed a bit ugly, as they get
upcased).

Cheers,
Maciej

Alessio

unread,
Dec 10, 2007, 3:10:51 PM12/10/07
to
In general, you can use

(cl-who:with-html-output-to-string (s)
(your-print-function some-value s))

i.e. inside the body of cl-who:with-html-output-to-string, s is bound
to a stream you can write to, just like with-output-to-string.

cheers
Alessio

Slobodan Blazeski

unread,
Dec 10, 2007, 3:19:27 PM12/10/07
to

Many thanks Sohail, it solved my problem

Slobodan

Slobodan Blazeski

unread,
Dec 10, 2007, 3:39:42 PM12/10/07
to

Well in my case that is expected behaviour, thanks for noticing .
Thanks to everybody for their advices.

Slobodan

Slobodan Blazeski

unread,
Dec 11, 2007, 4:16:17 AM12/11/07
to
Thanks to your help guys I finished my patch and added a small
tutorial at http://tourdelisp.blogspot.com/2007/12/adding-new-weblocks-type.html
if you have any comment of my code I will be happy to hear it.

cheers
Slobodan

0 new messages