2011-01-02 2 views
0

cl-who (특히 with-html-output-to-stringwith-html-output)을 사용하는 데 문제가 있는지 또는 Common Lisp을 이해하는 데 문제가 있는지 확실하지 않습니다. Lisp을 사용하는 나의 첫번째 프로젝트). 이 기능, 즉 사용하는 경우함수를 사용하여 cl-who : with-html-output을 무시하는 매개 변수

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

기능과 인쇄 문을 추가

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

은 "사용자 이름"문자열이 성공적으로 출력 (여전히 HTML에서 무시를) ... 어떤 아이디어는 어떻게이 발생할 수 있습니다?

hunchentoot과 함께 사용하기 위해 cl-who:with-html-output-to-string 내에서이 함수를 호출합니다.

답변

2

이 상황은 "문자열이나 키워드가 아닌 양식 ..."아래의 CL-WHO evaluation rules에 설명되어 있습니다. (:label :for name label)은 해당 규칙에 해당되며 방금 평가되었지만 아무런 결과도 출력하지 않으므로 효과가 없습니다 . 쉬운 수정 : 대신 (str label)을 사용하십시오.

관련 문제