]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Adding for the ability of ui-modules to add something at the end of the body of a...
authorElias Torres <elias@torrez.us>
Mon, 15 Feb 2010 05:10:11 +0000 (00:10 -0500)
committerBen Darnell <bdarnell@beaker.local>
Fri, 2 Apr 2010 18:40:56 +0000 (11:40 -0700)
tornado/web.py

index 072b261c40d1db5ca9fc7f6600954fa1252ab89e..e556666854ceb6b0b2548ddf1523938d450c73e8 100644 (file)
@@ -339,6 +339,7 @@ class RequestHandler(object):
         css_embed = []
         css_files = []
         html_heads = []
+        html_bodies = []
         for module in getattr(self, "_active_modules", {}).itervalues():
             embed_part = module.embedded_javascript()
             if embed_part: js_embed.append(_utf8(embed_part))
@@ -358,6 +359,8 @@ class RequestHandler(object):
                     css_files.extend(file_part)
             head_part = module.html_head()
             if head_part: html_heads.append(_utf8(head_part))
+            body_part = module.html_body()
+            if body_part: html_bodies.append(_utf8(body_part))
         if js_files:
             # Maintain order of JavaScript files given by modules
             paths = []
@@ -398,7 +401,9 @@ class RequestHandler(object):
         if html_heads:
             hloc = html.index('</head>')
             html = html[:hloc] + ''.join(html_heads) + '\n' + html[hloc:]
-
+        if html_bodies:
+            hloc = html.index('</body>')
+            html = html[:hloc] + ''.join(html_bodies) + '\n' + html[hloc:]
         self.finish(html)
 
     def render_string(self, template_name, **kwargs):
@@ -1329,6 +1334,10 @@ class UIModule(object):
         """Returns a CSS string that will be put in the <head/> element"""
         return None
 
+    def html_body(self):
+        """Returns an HTML string that will be put in the <body/> element"""
+        return None
+
     def render_string(self, path, **kwargs):
         return self.handler.render_string(path, **kwargs)