I'm trying to build a personal Website via hunchentoot and cl-who, but I'm occurring an semantic error in the following code:
(defun index ()
(standart-page (:title "~apb")
(dolist (article (articles))
(cl-who:htm
(:ul
(:li (format nil "~a: ~a" (article-date article) (article-title article))))))))
"standart-page" is a macro:
(defmacro standart-page ((&key title) &body body) `(cl-who:with-html-output-to-string (*standart-output* nil :prologue t :indent t)
(:html :xmlns "http://www.w3.org/1999/xhtml"
:xml\:lang "de"
:lang "de"
(:head
(:title ,title)
(:body
(:div :id "wrapper"
(:div :id "header"
(:h1 "~apb"))
(:div :id "content"
,@body)))))))
The evaluation of "(index)" (with one test article in "(articles)" returns:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='de' lang='de'>
<head>
<title>
~apb
</title>
<body>
<div id='wrapper'>
<div id='header'>
<h1>
~apb
</h1>
</div>
<div id='content'>
<ul>
<li>
</li>
</ul>
</div>
</div>
</body>
</head>
</html>
By looking at the <li>..</li>
tags I was wondering why there is no output. I think there's something wrong with the format function but I cant't figure out what.
Looking at the examples of usage on the CL-WHO site I don't think you can just do a format that returns a string. All of their examples either use custom output functions (for example fmt) that appear to write to a dynamic variable under the hood. In the example of code generated by CL-WHO you see this as a (format http-output-stream ....)
line in the macro expansion.
This would explain why you're not getting any output, you just need to use their custom output writers instead of the (format nil ..)
that you're using. You probably want something like
(fmt "~a: ~a" (article-date article) (article-title article))