http://users.jyu.fi/~tjlahton/cgi-bin/tiea2080/ohjaus4/templates/reseptit.html

<!DOCTYPE html>
<html>

<head>
  <title>Reseptit</title>
</head>

<body>

<h1>Reseptit</h1>

{{reseptit}}

<table>
<caption>Reseptit</caption>
{%for r in reseptit:%}
<tr><th>{{r['nimi']}}</th>
<td>{{r['kuvaus']}}</td>
<td>{{r['henkilomaara']}}</td>
{%endfor%}
</table>

<p>Sama kuin edellä, mutta käytetään indeksejä eikä kenttien nimiä</p>
<table>
<caption>Reseptit</caption>
{%for r in reseptit:%}
<tr><th>{{r[0]}}</th>
<td>{{r[1]}}</td>
<td>{{r[2]}}</td>
{%endfor%}
</table>


<table>
<caption>Ruokalajit</caption>
{%for r in ruokalajit:%}
<tr><th>{{r['nimi']}}</th>
<td>{{r['kuvaus']}}</td>
{%endfor%}
</table>


{%for r in ruokareseptit:%}
        {%if not loop.previtem or loop.previtem['ruokalaji'] != r['ruokalaji']:%}
            <h2>{{r['ruokalaji']}}</h2>
        {%endif%}
            <p>{{r['resepti']}}</p>
{%endfor%}

<p>Sama kuin edellä mutta käyttäen listaa</p>

{%for r in ruokareseptit:%}
        {%if not loop.previtem or loop.previtem['ruokalaji'] != r['ruokalaji']:%}
            {% if loop.previtem %}
                    </ul>
            {%endif%}
                    <h2>{{r['ruokalaji']}}</h2>
                    <ul>
        {%endif%}
            <li>{{r['resepti']}}</li>

        {% if loop.last %}
            </ul>
        {%endif%}
{%endfor%}

<p>Myös ne ruokalajit joihin ei liity reseptejä</p>

{%for r in ruokareseptit_all:%}
        {%if not loop.previtem or loop.previtem['ruokalaji'] != r['ruokalaji']:%}
            <h2>{{r['ruokalaji']}}</h2>
        {%endif%}
            {%if r['resepti'] %}
                <p>{{r['resepti']}}</p>
            {%endif%}
{%endfor%}

<p>Sama kuin edellä mutta käyttäen listaa</p>


{%for r in ruokareseptit_all:%}
        {%if not loop.previtem or loop.previtem['ruokalaji'] != r['ruokalaji']:%}
            {% if loop.previtem and loop.previtem['resepti'] %}
                    </ul>
            {%endif%}
                    <h2>{{r['ruokalaji']}}</h2>
            {%if r['resepti'] %}
                        <ul>
                        <li>{{r['resepti']}}</li>
            {%endif%}
        {%else%}
                        <li>{{r['resepti']}}</li>

        {%endif%}

        {% if loop.last and loop.previtem['resepti']%}
            </ul>
        {%endif%}
{%endfor%}



</body>
</html>