Commits

Anonymous committed 4f19986

Added render-tag-content, to consolidate html rendering. Doing so removed
some duplicate code shared between defhtmltag and render-as-html.

Comments (0)

Files changed (1)

   (:documentation "Render the end of a tag")
   )
 
+(defgeneric render-tag-content (*current-tag*)
+  (:documentation "Render just the content portion of the tag (no styles or scripts):
+   usually, the start tag, the rendered body, and the end tag.  In tags
+   that have a custom html representation, this is usually the method overriden."
+		  )
+)
+
 (defgeneric render-as-html (some-expr)
   (:documentation "Return some expression as an HTML string")
   )
   (union-ordered (shared-style-sheets *current-tag* ) *page-style-sheets* )
   (union-ordered (shared-ready-scripts *current-tag* ) *page-ready-scripts* )
 
-  ;; TODO we can probably merge this method with the code in defhtmltag
-  ;; using the next 3 lines as the default if the tag doesn't declare
-  ;; an :html value -- perhaps add an optional lambda argument to 
-  ;; the method, where the lambda gets called here?
-  (render-tag-start *current-tag* )
-  (render-tag-body *current-tag* )
-  (render-tag-end *current-tag* )
+  (render-tag-content *current-tag* )
 )
 
 (defmethod render-as-html ( (some-expr t) )
     )
   )
 
+(defmethod render-tag-content ( (*current-tag* htmltag) )
+  (render-tag-start *current-tag* )
+  (render-tag-body *current-tag* )
+  (render-tag-end *current-tag* )
+  )
+
 ;;;------------------------------------------------------------------------------------
 ;;; Functions
 ;;;------------------------------------------------------------------------------------
 	       )
 	    )
 
-
      ,(when as-html
-	    `(defmethod render-as-html ( (*current-tag*  ,name) )
-	       ;; we still do this, even though we are not rendering the tag
-	       ;; with default behavior
-	       (union-ordered (shared-script-libraries *current-tag* ) *page-script-libraries* )
-	       (union-ordered (shared-scripts *current-tag* ) *page-scripts* )
-	       (union-ordered (shared-styles *current-tag* ) *page-styles* )
-	       (union-ordered (shared-style-sheets *current-tag* ) *page-style-sheets* )
-	       (union-ordered (shared-ready-scripts *current-tag* ) *page-ready-scripts* )
-	     
+	    `(defmethod render-tag-content ( (*current-tag* ,name) )
 	       ;; render the as-html expression instead of the usual rendering
 	       (render-as-html (tags ,as-html) )
 	       )
 (defmacro page (&rest raw-body)
   "Interpret the raw body as html markup, and return a complete HTML page"
   `(multiple-value-bind (page-attributes body) (separate-initializer-and-body (quote ,raw-body))
-     (declare (ignorable page-attributes) )
+     (declare (ignorable page-attributes body ) )
      (multiple-value-bind (page-content *page-style-sheets* *page-styles* *page-script-libraries* *page-scripts* *page-ready-scripts*) 
 	   (html (list ,@raw-body) )
 					; now render the page