开发者

function using cl-who:with-html-output ignoring parameter

开发者 https://www.devze.com 2023-02-02 05:19 出处:网络
I\'m not sure whether this is an issue with my use of cl-who (specifically with-html-output-to-string and with-html-output) or an issue with my understanding of Common Lisp (as this is my first projec

I'm not sure whether this is an issue with my use of cl-who (specifically with-html-output-to-string and with-html-output) or an issue with my understanding of Common Lisp (as this is my first project using Lisp).

I created a function to create form fields:

开发者_如何学JAVA
(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))))

When using this function, ie: (form-field "text" "username" "Username") the parameter label seems to be ignored... the HTML output is:

<div class="field"><label for="username"></label>
<input type="text" name="username"/></div>

instead of the expected output:

<div class="field"><label for="username">Username</label>
<input type="text" name="username"/></div>

If I modify the function and add a print statement:

(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))))

The "Username" string is successfully output (but still ignored in the HTML)... any ideas what might cause this?

Keep in mind, I'm calling this function within a cl-who:with-html-output-to-string for use with hunchentoot.


This situation is described in the CL-WHO evaluation rules under "A form which is neither a string nor a keyword..." (:label :for name label) falls under that rule, and it's just evaluated, but it doesn't output anything so it has no effect. One easy fix: use (str label) instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消