Browse files

Split the formlet system into three files (one of which just declares…

… the package)
  • Loading branch information...
1 parent 363a89e commit 6684296d2c5cae0ec8eb71ded8d96f2ddf6d1b1d ingram committed Oct 29, 2010
Showing with 29 additions and 28 deletions.
  1. +1 −0 .gitignore
  2. +0 −28 formlets.lisp
  3. +6 −0 package.lisp
  4. +22 −0 utility.lisp
View
1 .gitignore
@@ -0,0 +1 @@
+*~
View
28 formlets.lisp
@@ -1,33 +1,5 @@
-(defpackage :formlets
- (:use :cl :cl-who :hunchentoot)
- (:import-from :cl-ppcre :regex-replace-all)
- (:export :def-formlet))
(in-package :formlets)
-;;Predicates
-
-;;Utility
-(defmacro html-to-stout (&body body)
- `(with-html-output (*standard-output* nil :indent t) ,@body))
-
-(defun name->label (field-name)
- (string-capitalize (regex-replace-all "-" (string field-name) " ")))
-
-(defmacro error-html (key tag class)
- `(html-to-stout
- (if (getf e-list ,key) (htm (,tag :class ,class (str (getf e-list ,key)) (str ""))))))
-
-(defun show-general-error (e-list) (error-html :general-error :div "general-error"))
-(defun show-error (e-list key) (error-html key :span "inline-error"))
-
-(defun sym->keyword (s) (intern (symbol-name s) :keyword))
-
-(defun list->plist (a-list &optional acc)
- (if (not a-list)
- acc
- (let ((e (car a-list)))
- (list->plist (cdr a-list) (append acc `(,(sym->keyword e) ,e))))))
-
;;View related functions
(defun show-form-field (name type form-values form-errors)
(let* ((s-name (string name)) (l-name (string-downcase s-name)))
View
6 package.lisp
@@ -0,0 +1,6 @@
+(defpackage :cl-formlets
+ (:nicknames "formlets")
+ (:use :cl :cl-who :hunchentoot)
+ (:import-from :cl-ppcre :regex-replace-all)
+ (:export :def-formlet)
+ (:documentation "A package implementing auto-validating formlets for Hunchentoot"))
View
22 utility.lisp
@@ -0,0 +1,22 @@
+(in-package :formlets)
+
+(defmacro html-to-stout (&body body)
+ `(with-html-output (*standard-output* nil :indent t) ,@body))
+
+(defun name->label (field-name)
+ (string-capitalize (regex-replace-all "-" (string field-name) " ")))
+
+(defmacro error-html (key tag class)
+ `(html-to-stout
+ (if (getf e-list ,key) (htm (,tag :class ,class (str (getf e-list ,key)) (str ""))))))
+
+(defun show-general-error (e-list) (error-html :general-error :div "general-error"))
+(defun show-error (e-list key) (error-html key :span "inline-error"))
+
+(defun sym->keyword (s) (intern (symbol-name s) :keyword))
+
+(defun list->plist (a-list &optional acc)
+ (if (not a-list)
+ acc
+ (let ((e (car a-list)))
+ (list->plist (cdr a-list) (append acc `(,(sym->keyword e) ,e))))))

0 comments on commit 6684296

Please sign in to comment.