<commit_before>;; Copyright (c) <NAME>. All rights reserved.
;; The use and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
;; can be found in the file epl-v10.html at the root of this distribution. By
;; using this software in any fashion, you are agreeing to be bound by the
;; terms of this license. You must not remove this notice, or any other, from
;; this software.

;; compojure.html.form-helpers:
;; 
;; Functions for generating HTML forms and input fields.

(ns compojure.html.form-helpers
  (:use compojure.html.gen)
  (:use compojure.control)
  (:use compojure.str-utils)
  (:use clojure.contrib.def)
  (:use clojure.contrib.seq-utils))

;; Global parameters for easy default values

(defvar *params* {}
  "Parameter map var that form input field functions use to populate their
  default values.")

(defmacro with-params
  "Bind a map of params to *params*."
  [params & body]
  `(binding [*params* ~params]
    ~@body))

;; Form input fields

(defn- input-field
  "Creates a form input field."
  [type name value]
  [:input {:type  type
           :name  (str* name)
           :id    (str* name)
           :value value}])

(defn hidden-field
  "Creates a hidden input field."
  ([name]       (hidden-field name (*params* name)))
  ([name value] (input-field "hidden" name value)))

(defn text-field
  "Creates a text input field."
  ([name]       (text-field name (*params* name)))
  ([name value] (input-field "text" name value)))

(defn password-field
  "Creates a password input field."
  [name]
  (input-field "password" name ""))

(defn check-box
  "Creates a check box."
  ([name]
    (check-box name (*params* name)))
  ([name checked?]
    (check-box name checked? "true"))
  ([name checked? value]<commit_msg>Fixed nil values being added to input tag attributes<commit_after>;; Copyright (c) <NAME>. All rights reserved.
;; The use and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
;; can be found in the file epl-v10.html at the root of this distribution. By
;; using this software in any fashion, you are agreeing to be bound by the
;; terms of this license. You must not remove this notice, or any other, from
;; this software.

;; compojure.html.form-helpers:
;; 
;; Functions for generating HTML forms and input fields.

(ns compojure.html.form-helpers
  (:use compojure.html.gen)
  (:use compojure.control)
  (:use compojure.str-utils)
  (:use clojure.contrib.def)
  (:use clojure.contrib.seq-utils))

;; Global parameters for easy default values

(defvar *params* {}
  "Parameter map var that form input field functions use to populate their
  default values.")

(defmacro with-params
  "Bind a map of params to *params*."
  [params & body]
  `(binding [*params* ~params]
    ~@body))

;; Form input fields

(defn- input-field
  "Creates a form input field."
  [type name value]
  (let [name  (str* name)
        attrs {:type type, :name name, :id name}
        attrs (if value
                (assoc attrs :value value)
                attrs)]
    [:input attrs]))

(defn hidden-field
  "Creates a hidden input field."
  ([name]       (hidden-field name (*params* name)))
  ([name value] (input-field "hidden" name value)))

(defn text-field
  "Creates a text input field."
  ([name]       (text-field name (*params* name)))
  ([name value] (input-field "text" name value)))

(defn password-field
  "Creates a password input field."
  [name]
  (input-field "password" name ""))

(defn check-box
  "Creates a check box."
  ([name]
    (check-box name (*params* name)))
  ([name checked?]
    (check-box name checked? "true"))
  ([name checked? value]
{'fraction_non_alphanumeric': 0.12917771883289125, 'fraction_numerical': 0.003183023872679045, 'mean_word_length': 3.4053738317757007, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6522177', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1173, 'n_words': 453}