首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用cl-who:with-html-output忽略参数的函数

使用cl-who:with-html-output忽略参数的函数
EN

Stack Overflow用户
提问于 2011-01-02 09:43:37
回答 1查看 463关注 0票数 0

我不确定这是我使用cl-who (特别是with-html-output-to-stringwith-html-output)的问题,还是我对Common Lisp理解的问题(因为这是我使用Lisp的第一个项目)。

我创建了一个函数来创建表单域:

代码语言:javascript
复制
(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输出为:

代码语言:javascript
复制
<div class="field"><label for="username"></label>
<input type="text" name="username"/></div>

而不是预期的输出:

代码语言:javascript
复制
<div class="field"><label for="username">Username</label>
<input type="text" name="username"/></div>

如果我修改函数并添加一条print语句:

代码语言:javascript
复制
(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一起使用。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-02 19:57:11

这种情况在“既不是字符串也不是关键字的表单...”下的CL-WHO evaluation rules中进行了描述。(:label :for name label)属于该规则,它只是被评估,但它不输出任何内容,因此没有任何效果。一个简单的解决方法是:改用(str label)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4576702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档