Hello,
I've been trying to figure out how to do something in CL-WHO and haven't been able to get it yet, so I thought perhaps somebody on here might be able to help me out.
I'm working on an RSS / blog component on my website which is written in Lisp (running on top of Hunchentoot, specifically). Each entry in the blog consists of a file located in a hierarchy that composes a date: e.g. /blog/2008/05/02 for the entry of May 2nd, 2008. Each entry file is a Lisp file with the following structure:
((title . "The Title Goes Here") (description . "This is what gets shown in the RSS feed.") (body . (:div :id "content" (:p "This is the first paragraph in the entry.") (:p "Here's another paragraph with " (:a :href "/foo" "a link") " inside of it."))))
My goal is to use the Lisp reader to read the list into a variable, let's call it "content", and to pull out of "content" the things that I need to render. With RSS this was possible by using something like:
(cl-who:with-html-output (output) (:item (:title (cl-who:str (cdr (assoc :title content)))) (:description (cl-who:str (cdr (assoc :description content))))))
But I also want to render HTML pages constructed from the "body" part of the entry, something that would work like:
(with-open-file (input (site-file path)) (let ((content (read input))) (cl-who:with-html-output (output) (cdr (assoc :body content)))))
But evaluate (cdr (assoc :body content)) and use the result [in this case it would turn into the HTML template code that I wanted] rather than doing what seems to be the default behaviour of evaluating the expression but then outputting nothing. Is this possible with CL-WHO at this time? If not, would it be difficult to add such feature in a manner similar to how CL-WHO:STR and CL-WHO:HTM work?
Thanks for any help or ideas. I'm using version 0.11.1 running under SBCL 1.0.11 on Ubuntu GNU/Linux 8.04.1
On Mon, 28 Jul 2008 11:07:53 +0200 Jens Teich info@jensteich.de wrote:
... similar to how CL-WHO:STR and CL-WHO:HTM work?
Have you already discovered cl-who:fmt?
This won't do it. For example:
METASYNTAX> (cl-who:with-html-output (*standard-output*) (cl-who:fmt "~A" (car '((:p "foo"))))) (P foo) NIL
I need something like:
METASYNTAX> (cl-who:with-html-output (*standard-output*) (cl-who:evaluate (car '((:p "foo"))))) <p>foo</p> NIL