django_coverage_plugin
django_coverage_plugin copied to clipboard
{% endblock %} marked as missing in templates solely used as parent templates
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?
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).