Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding for the ability of ui-modules to add something at the end of t…

…he body of a document.
  • Loading branch information...
commit e520b21ed297cb92706356e6a0877df02205564c 1 parent 794685b
@eliast eliast authored Ben Darnell committed
Showing with 10 additions and 1 deletion.
  1. +10 −1 tornado/web.py
View
11 tornado/web.py
@@ -339,6 +339,7 @@ def render(self, template_name, **kwargs):
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 @@ def render(self, template_name, **kwargs):
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 @@ def render(self, template_name, **kwargs):
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 @@ def html_head(self):
"""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)
Please sign in to comment.
Something went wrong with that request. Please try again.