django_coverage_plugin icon indicating copy to clipboard operation
django_coverage_plugin copied to clipboard

{% endblock %} marked as missing in templates solely used as parent templates

Open grondman opened this issue 4 years ago • 1 comments

I'm using a parent template (never used on its own but always extended from) with the following code snippet:

    <main id="{{ page }}">
        {% if page != "home" %}
            <div class="container py-4">
        {% endif %}
        {% block content %}
        {% endblock content %}
        {% if page != "home" %}
            </div>
        {% endif %}
    </main>

The {% endblock content %} line is always marked as missing. I guess this is because I'm never using this template on its own for a view and that the contents of the actual block are always filled by a child template, but then the coverage tool mistakenly thinks that is has not seen the endblock tag in the parent template.

I've solved it now by putting both block and endblock on the same line, but it still looks like something that can be fixed?

grondman avatar Sep 23 '20 19:09 grondman

This can be a problem as linters e.g. djlint will automatically reformat the {% endblock %} to the next line, so requires overriding the linter (as there does not appear to be any way to add an ignore pragma to the template).

danjac avatar Nov 19 '22 11:11 danjac