3

[:tr]没有(do (html5 ..))当我使用具有 for 循环的嵌套 let 语句时,我无法运行内部。

(defpartial column-settings-layout [& content]

  (html5
    [:head
     [:title "my-noir-proj"]
            (include-css "assets/css/bootstrap.css")
     ]
    [:body
     [:div
      [:div
      [:image {:src "assets/img/ceva.gif" :alt "ceva-logo"}]
        (toolbar)
        ]
     [:div {:style "overflow: auto; overflow-x: hidden"}
          content]      
      [:form {:id "col_settings_form" :name "col_settings_form" :method="post" :enctype="multipart/form-data"}
       [:input {:type "button" :value "Save" :onclick "ajaxWithSerialize('save_cols_response_div','/save_cols_settings',$(col_settings_form).serialize());"}]
       [:table {:class "table-striped" :border "1"}

            [:tr [:td {:id "processing_status" }  ][:td {:id "save_cols_response_div" :colspan 6}  ]]
            [:tr [:td ][:td {:colspan "3"} "SP" ] [:td {:colspan "3"} "WP"]]
            (let [wp_settings (session/get :wp_settings)
                 sp_settings (session/get :sp_settings)]

                (do (html5 [:tr [:td {:colspan "7"} "jhyghjghj"]]))
                    (for [col (:all_cols (session/get :setting_doc))]
                      (let 
                        [
                         dest_station (keyword (session/get :dest_station))
                         ;col_nm  (:col_nm (nth col 1))
                         field_nm  (nth col 0)                   
                         sp_col_nm (:col_nm (field_nm (dest_station sp_settings)))
                         wp_col_nm (:col_nm (field_nm (dest_station wp_settings)))                                
                         sp_editable (:editable (field_nm (dest_station sp_settings)))
                         wp_editable (:editable (field_nm (dest_station wp_settings)))

                         ]   
                        (do (html5 [:tr[:td "sfsdfgfds"]] 
                          [:tr 
                           [:th { :align "right"  :class "input-small" } field_nm ] 
                           [:td {:title sp_editable }[:input {:type "text" :class "input-large" :name (str "page_sp[" dest_station "][" field_nm "][col_nm]")  :value sp_col_nm } ] ] 
                           [:td [:input {:type "checkbox" :name (str "page_sp[" dest_station "][" field_nm "][col_nm]") :value field_nm}]]
                         [:td [:input {:type "checkbox" :name (str "page_sp[" dest_station "][" field_nm "][editable]") :value field_nm}]]
                         [:td {:title wp_editable }[:input {:type "text" :class "input-large" :name (str "page_wp[" dest_station "][" field_nm "][col_nm]")  :value wp_col_nm} ] ] 
                           [:td [:input {:type "checkbox" :name (str "page_wp[" dest_station "][" field_nm "][col_nm]") :value field_nm}]] 
                         [:td [:input {:type "checkbox" :name (str "page_wp[" dest_station "][" field_nm "][editable]") :value field_nm}]]
                          ]))
                  )
                    )

            )
       ]
       ]
         (footer)

    ;my includes of js and css
    ]]))
4

2 回答 2

3

你的问题很可能是你试图做类似的事情

[:tr (for ... [:td .])]

这导致无效的打嗝格式

[:tr [[:td ..] [:td ..] ..]] ; note the vector of vectors inside the :tr

打嗝期望的地方

[:tr [:td ..] [:td ..] ..] ; :td vectors are direct elements of :tr

要获得预期的格式,您需要类似

(into [:tr] (for ... [:td .]))

更新:您的 (html..) 构造也解决了这个问题的原因是它将整个格式化的打嗝标签序列转换为单个 HTML 字符串。你可以放弃do- 它没有做任何有用的事情。

于 2012-03-21T14:17:44.013 回答
2

你想改为写

(html5 
 [:tr ...]
 (for ...))

甚至只是

(cons [:tr ...]
      (for ...])

do是针对副作用的,打嗝是纯功能性的,没有副作用。您可以使用列表来对文档元素进行分组,而不是使用do对副作用进行分组。

于 2012-03-21T19:17:33.030 回答