[cl-who-devel] Interpolate lisp code inside the tag body

Sebastian Tennant sebyte at smolny.plus.com
Mon Aug 1 18:23:15 UTC 2011


Quoth Matus Kmit <simply.nitaai at gmail.com>:
> Does that mean that one should use only with-html-output-to-string for
> publishing

Yes.  Let's say your dispatch handler (a hunchentoot term) calls function
home-page, then home-page should look like this:

(defun home-page ()
  (with-html-output-to-string (*http-stream*)
    (:p ...)
    ...))

where *http-stream* is defined as a special variable, like so:

(defun *http-stream* nil)

Now, let's assume home-page includes a call to function navbar.

navbar doesn't need to use w-h-o-t-s.  This will suffice:

(defun (navbar ()
  (with-html-output (*http-stream*)
    (:div :id "navbar" ...)
    ...))

In short, only the 'top-level' function called by your dispatch handler
needs to use w-h-o-t-s.

Hope this helps.

Sebastian





More information about the Cl-who-devel mailing list