Macro: defview

Documentation

Defines a named view.

Source

(defmacro defview (name &body definition)
  "Defines a named view."
  (multiple-value-bind (qualifiers required-args other-args body) (parse-method-definition definition) 
    (let* ((fn-name (symcat 'view- name))
	   (def-generic (if (fboundp fn-name)
			    nil
			    ;; make the generic function for the view
			    (let ((untyped-fnlist (mapcar (fn (arg-spec)
							    (if (consp arg-spec)
								(car arg-spec)
								arg-spec))
							  required-args)))
			      `(defgeneric ,fn-name (,@untyped-fnlist &allow-other-keys)))))) 
      `(progn
	 ,@(if def-generic
	       (list def-generic
		     `(setf (gethash ',(symbol-name fn-name) *defined-views*)
			    (symbol-function ',fn-name))))
	 
	 (defmethod
	     ,fn-name
	     ,@qualifiers
	   ,(append required-args other-args) 
	   (html ,@body))))))
Source Context