My first step was to develop an HTML template. An HTML template is an HTML document with one or more fields added. Because of Slither, I used the << and >> symbols to delimit a field. As an example, instead of writing
<h1>Header 1</h1>
one could put in a template
<h1><<header_1>></h1>
The Python program will substitute the appropriate text for the <<header_1>> field before sending the HTML text to the browser to be displayed.
Click here to see an example template.
Because of the way text is substituted in a Python program, you can have more than one field in an HTML template with the same name. As an example, you could have the following two lines in an HTML template
<title><<header_1>></title>...<h1><<header_1>></h1>
and the Python program would substitute the same value for both fields.
A field is not limited to simple text substitution. As an example, a Python program could use the field <<site_selection>> to generate a dynamic drop down selection box based on values from a database.
It's better for maintenance and the separation of display logic from processing logic to use as few fields as possible in the template. At the extreme, the entire HTML template could consist of the single field
<<template>>
with all of the HTML code being generated by the Python program. On the other hand, you don't want to maintain several templates that could be consolidated with the use of a few more fields.
Previous Page: Environment, Top Page: Index, Next Page: Python Module Flow