我不确定这是我使用cl-who (特别是with-html-output-to-string和with-html-output)的问题,还是我对Common Lisp理解的问题(因为这是我使用Lisp的第一个项目)。
我创建了一个函数来创建表单域:
(defun form-field (type name label)
(cl-who:with-html-output (*standard-output* nil)
(:div :class "field"
(:label :for name label)
(:input :type type :name name))))当使用这个函数时,例如:(form-field "text" "username" "Username")参数label似乎被忽略了...HTML输出为:
<div class="field"><label for="username"></label>
<input type="text" name="username"/></div>而不是预期的输出:
<div class="field"><label for="username">Username</label>
<input type="text" name="username"/></div>如果我修改函数并添加一条print语句:
(defun form-field (type name label)
(cl-who:with-html-output (*standard-output* nil)
(print label)
(:div :class "field"
(:label :for name label)
(:input :type type :name name))))"Username“字符串已成功输出(但在HTML中仍被忽略)...你知道这是什么原因造成的吗?
请记住,我在cl-who:with-html-output-to-string中调用此函数是为了与hunchentoot一起使用。
发布于 2011-01-02 19:57:11
这种情况在“既不是字符串也不是关键字的表单...”下的CL-WHO evaluation rules中进行了描述。(:label :for name label)属于该规则,它只是被评估,但它不输出任何内容,因此没有任何效果。一个简单的解决方法是:改用(str label)。
https://stackoverflow.com/questions/4576702
复制相似问题