From: Elias Torres
Date: Mon, 15 Feb 2010 05:10:11 +0000 (-0500)
Subject: Adding for the ability of ui-modules to add something at the end of the body of a...
X-Git-Tag: v1.0.0~62
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e520b21ed297cb92706356e6a0877df02205564c;p=thirdparty%2Ftornado.git
Adding for the ability of ui-modules to add something at the end of the body of a document.
---
diff --git a/tornado/web.py b/tornado/web.py
index 072b261c4..e55666685 100644
--- a/tornado/web.py
+++ b/tornado/web.py
@@ -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('')
html = html[:hloc] + ''.join(html_heads) + '\n' + html[hloc:]
-
+ if html_bodies:
+ hloc = html.index('
')
+ 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
element"""
return None
+ def html_body(self):
+ """Returns an HTML string that will be put in the
element"""
+ return None
+
def render_string(self, path, **kwargs):
return self.handler.render_string(path, **kwargs)