在“使用Clojure进行Web开发”一书中所说的代码
(defn registration-page []
(layout/common
(form-to [:post "/register"]
(label "id" "screen name")
(text-field "id")
[:br]
(label "pass" "password")
(password-field "pass")
[:br]
(label "pass1" "retype password")
(password-field "pass1")
[:br]
(submit-button "create account"))))
可以使用辅助函数重写,如下所示:
(defn control [field name text]
(list (on-error name format-error)
(label name text)
(field name)
[:br]))
(defn registration-page []
(layout/common
(form-to [:post "/register"]
(control text-field :id "screen name")
(control password-field :pass "Password")
(control password-field :pass1 "Retype Password")
(submit-button "Create Account"))))
我的问题是:在替代代码中,为什么参数 name 的值不是字符串?例如,为什么(控制文字字段:id “屏幕名称”),而不是(控制文字字段“id”“屏幕名称”)?