【发布时间】:2018-12-20 20:57:15
【问题描述】:
我正在使用 cl-who(通过 hunchentoot),到目前为止完全成功,但是有一件事我无法弄清楚,而且我的解决方法很丑陋,所以我希望有一个简单的解决方法。我的 hunchentoot 简单处理程序调用看起来像这样的函数:
(defun foo ()
(with-html-output-to-string
(*standard-output* nil :prologue t)
(:html
(:body (htm :br :hr "foo" :hr ...etc...))))
一切都很好。
但是,当我想从 foo 中调用辅助函数以执行...任何我想做的子工作时,我无法弄清楚如何使 CL-WHO 的 HTM 上下文通过调用。例如,这很好用:
(defun foo ()
(with-html-output-to-string
(*standard-output* nil :prologue t)
(:html
(:body (htm :br :hr "foo" :hr (bar)))))
(defun bar ()
(format t "This will show up in the html stream"))
但这不起作用:
(defun bar ()
(with-html-output-to-string
(*standard-output* nil :prologue t)
(htm "This will NOT show up in the html stream")))
(我已经尝试了各种操作,但无济于事。)
我确定我做错了一些简单的事情;必须在任何 subfn 中恢复为 t 格式是非常丑陋的,尤其是。 bcs 我不能使用 cl-who 方便的 html 宏。
【问题讨论】:
-
为什么不只是
(defun bar() "This will NOT show up in the html stream")?你没有做任何需要htm的事情。 -
摆脱
:prologue t。这应该只在顶级 HTML 文档中使用,而不是在其他标签内。
标签: lisp common-lisp hunchentoot cl-who