Вопрос

All the examples I've seen so far for cl-who work like this:

(with-html-output-to-string (s)
   (:HTML (:HEAD (:TITLE "hello")) (:BODY (:DIV "world"))))

Which works fine. However, I wanted to use with-html-output-to-string with a variable, instead of a hardcoded html tree; if *p* has (:HTML (:HEAD (:TITLE "hello")) (:BODY (:DIV "world"))) and I do this

(with-html-output-to-string (s)
   *p*)

I get "" as a result. I guess that as with-html-output-to-string is a macro, it's last argument is never evaluated. Is there any way I can get around this?

Это было полезно?

Решение

Use cl-who:str; check the examples at http://weitz.de/cl-who/#example.

If you do:

(with-html-output-to-string (s)
   (str *p*))

you'll get the expected output.

Другие советы

Passing around partial html trees as lisp forms is not the expected way in cl-who, but you could use some cl-who internals (apply tree-to-commands) to write a litte wrapper.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top