8: Common Templates

< Previous Step Next Step >


There are templates for sections of HTML and logic that are common across more than one page.


There are only two common templates at this point. They will be called through "Common template valves" or renderer functions, in uag.py.

# header render
def header_render (template_values):
# to do: add data to template_values
path = os.path.join(os.path.dirname(__file__), 'header.html')
return template.render(path, template_values)

# footer render
def footer_render (template_values):
# to do: add data to template_values
path = os.path.join(os.path.dirname(__file__), 'footer.html')
return template.render(path, template_values)


header.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>{{ title }}</title>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" >
</head>
<body>
<a href="{{ url }}"><font size="+3"><b>{{ title }}</b></font></a><br>
<div width="100%" align="right">
{% if username %}
{% if bad_user %}
<span style="color:#00aa00;">
<b>You are not yet authorized
to use this application</b>
</span>
{% endif %}
<b>{{ username }}</b>
<b><a href="/logout/">Logout</a></b>
{% else %}
<b><a href="/login/">Login</a></b>
{% endif %}
<br><br>
</div>
<br><br>



footer.html:

</body>
</html>

Comments