Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hiccup code not responding without (do (html5 at each level

Tags:

clojure

hiccup

I am not able to run inner [:tr] without (do (html5 ..)) when i am using nested let statement having for loop.

(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
    ]]))
like image 515
chirag ghiyad Avatar asked Dec 06 '25 09:12

chirag ghiyad


1 Answers

Your problem is likely that you're attempting to do something like

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

which results in the invalid hiccup format

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

where hiccup expects

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

To get the expected formatting, you need something like

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

update: the reason your (html..) construct also fixes this problem is that it turns the whole sequence of formatted hiccup tags into a single HTML string. And you can drop the do - it's not doing anything useful.

like image 78
Joost Diepenmaat Avatar answered Dec 08 '25 00:12

Joost Diepenmaat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!