我正在通过 Adam Tornhill 的 Lisp For The Web 工作,我一直在生成一个包含 li 元素的 html 页面。
(with-html-output (*standard-output* nil :prologue t :indent t)
(htm
(:li (:a :href "Link" "Vote!")
)))
当我编译它时,以下输出被打印到 REPL
(with-html-output (*standard-output* nil :prologue t :indent t)
(htm
(:li (:a :href "Link" "Vote!")
)))
<!DOCTYPE html>
<li>
<a href='Link'>Vote!
</a>
</li>
"
<li>
<a href='Link'>Vote!
</a>
</li>"
通常不添加输出末尾的字符串,并且包含此字符串的站点不会在 hunchentoot 中呈现。在 :li 周围添加 :ol 并没有帮助,我想保持示例最小化。
书中的代码作为参考:
(define-easy-handler (retro-games :uri "/retro-games") ()
(standard-page (:title "Top Retro Games")
(:h1 "Vote on your all time favourite retro games!")
(:p "Missing a game? Make it available for votes " (:a :href "new-game" "here"))
(:h2 "Current stand")
(:div :id "chart" ; Used for CSS styling of the links.
(:ol
(dolist (game (games))
(htm
(:li (:a :href (format nil "vote?name=~a" (escape-string ; avoid injection attacks
(name game))) "Vote!")
(fmt "~A with ~d votes" (name game) (votes game)))))))))