2012-03-21 28 views
2

我不能当我使用具有循环嵌套的let语句不(do (html5 ..))运行内[:tr]打嗝的代码,而不(做(HTML5在每个级别

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

回答

2

你的问题很可能是你”再试图做类似

[: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 - 它没有做任何有用的事情。

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

do是用于副作用,打嗝是纯粹的功能,没有副作用。你需要返回一个有更多东西的矢量,而不是以某种方式返回一个矢量,然后返回另一个矢量。