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

<div style="width: 800px;">
    <h2>
        {% if app_name != None %}
            {% if app_version != None %}
                {{app_name}} (v{{app_version}})
            {% else %}
                {{app_name}}
            {% endif %}

        {% else %}
            Crash Report
        {% endif %}
    </h2>
<hr>
    {% if user is none %}
        <p>A crash was detected on {{date}} at {{time}}.</p>
    {% else %}
        <p>A crash was detected on {{date}} at {{time}} from user {{user}}.</p>
    {% endif %}

</div>

<div style="width: 800px;">
    <h4>Traceback (most recent call last):</h4>
    <b>
    {% for tb in traceback %}
        <DL style="background-color:#FFF099; border-style:solid; border-width: 1px; padding: 10px;" >
            File {{tb['file']|e}}, line: {{tb['line']|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 " >
            {{error|e}}
        </DL>
    </b>

    <hr>

    <h4>Source Code: {{traceback[-1]['file']}}</h4>

    <div style="width: 800px; background-color:#FFF099; border-style:solid; border-width: 1px; padding: 10px;">
        <ol start="{{traceback[-1]['func_line']}}">
            {% for n, line in traceback[-1]['source'] %}
                {% set stripped_line = line.replace('    ', '') %}
                {% set indent = 30 * (line.count('    ')-1) %}
                {% if n == traceback[-1]['error_lineno'] %}
                    <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 {{traceback[-1]['module']|e}}</h4>
    <table border="1" style="width:800px">
        {% for field, value in traceback[-1]['local_vars'] %}
            <tr>
                <td style="width:30%">{{ field|e }}</td>
                <td>{{ value|e }}</td>
            </tr>
        {% endfor %}
    </table>

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


</div>

</body>
</html>