<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Crash Report</title>
</head>
<body>

<div style="width: 800px;">
    <h2>
        {% if info['Application Name'] != None %}
            {% if info['Application Version'] != None %}
                {{info['Application Name']}} (v{{info['Application Version']}})
            {% else %}
                {{info['Application Name']}}
            {% endif %}

        {% else %}
            Crash Report
        {% endif %}
    </h2>
<hr>
    {% if info['User'] is none %}
        <p>A crash was detected on {{info['Date']}} at {{info['Time']}}.</p>
    {% else %}
        <p>A crash was detected on {{info['Date']}} at {{info['Time']}} from user {{info['User']}}.</p>
    {% endif %}

</div>

<div style="width: 800px;">
    <h4>Traceback (most recent call last):</h4>
    <b>
    {% for tb in info['Traceback'] %}
        <DL style="background-color:#FFF099; border-style:solid; border-width: 1px; padding: 10px;" >
            File {{tb['File']|e}}, line: {{tb['Error Line Number']|e}} in {{tb['Module']|e}}
            <DD>
                {{tb['Error Line']|e}}
            </DD>
        </DL>
    {% endfor %}
        <DL style="background-color:#FFF099; border-style:solid; border-width: 1px; padding: 10px " >
            {{info['Error Type']|e}} {{info['Error Message']|e}}
        </DL>
    </b>

    <hr>

    <h4>Source Code: {{info['Traceback'][-1]['File']}}</h4>

    <div style="width: 800px; background-color:#FFF099; border-style:solid; border-width: 1px; padding: 10px;">
        <ol start="{{info['Traceback'][-1]['Module Line Number']}}">
            {% for line in info['Traceback'][-1]['Source Code'].split('\n') %}
                {% set stripped_line = line.replace('    ', '') %}
                {% set indent = 30 * (line.count('    ') - 1) %}
                {% if info['Traceback'][-1]['Module Line Number'] + loop.index0 == info['Traceback'][-1]['Error Line Number'] %}
                    <li style="background-color:#BB0000; padding-left:{{indent}}px;">
                        {{stripped_line}}
                    </li>
                {% else %}
                    <li style="padding-left: {{indent}}px;">{{stripped_line}}</li>

                {% endif %}
            {% endfor %}
        </ol>
    </div>

    <hr>

    <h4>Local Variables in the scope of {{info['Traceback'][-1]['Module']|e}}</h4>
    <table border="1" style="width:800px">
        {% for field, value in info['Traceback'][-1]['Local Variables'] %}
            <tr>
                <td style="width:30%">{{ field|e }}</td>
                <td>{{ value|e }}</td>
            </tr>
        {% endfor %}
    </table>

    <h4>Object Inspection in the scope of {{info['Traceback'][-1]['Module']|e}}</h4>
    <table border="1" style="width:800px">
        {% for field, value in info['Traceback'][-1]['Object Variables'] %}
            <tr>
                <td style="width:30%">{{ field|e }}</td>
                <td>{{ value|e }}</td>
            </tr>
        {% endfor %}
    </table>


</div>

</body>
</html>