Rendering templates
We have been returning plain strings so far, and that's been handy for a while. However, things get pretty complicated if you have to return more information with a more detailed and structured page to the user. This is where this string approach gets very complicated and hard to manage.
That's where templates come into play. Just to recap, the idea of a template is to have some placeholder within the content, where the actual values will be rendered so that you can pass to them. There are many templating libraries (each have their different syntax as well at times), but one of the most widely used one is the templating language, which is used by Django, the popular web framework. It is quit intuitive and easy to understand. There's another third-party library named jinja2
that adopts the Django template language in the form of a separate library. Google App Engine has both the Django templates and jinja2
available. If you want to use some other templating...