=========
Templates
=========
Generating HTML from Python can be tiresome. Let's put Jinja2 templates
to work in Flask, while showing some PyCharm features such as Emmet
for code completion. For now, though, we'll just convert one view,
the home page, to use a template.
`Source for this step `_
Steps
=====
#. In ``app.py``, let's change the return value of ``home_page`` to
return a template. Replace that line and instead, type
``return render_template`` and press ``Alt-Enter``.
#. Select ``import this name`` and select the first choice, from ``flask``.
#. Finish typing that line, resulting in:
.. code-block:: python
@app.route('/')
def home_page():
return render_template('index.html', title='Home Page')
#. PyCharm warns us that ``Template file 'index.html' not found``. Let's create
it.
#. Right-click in the Project Tool window on the ``templates`` folder and
select ``New -> File``. Give it a name of ``index.html`` and click
``OK``.
#. Let's use `Emmet `_
as a way to type fast. In the empty file, type
``html>head>title`` and press ``tab``. PyCharm will generate much of the markup,
leaving your cursor in the ````.
#. In the ````, type ``Todo App: {{ title }}`` and press
``Shift-Enter`` to start a new line.
#. Type ``body>h1`` and press ``tab``. Inside the generated ``