Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
grondman opened this issue Sep 23, 2020 · 1 comment

Comments

@grondman
Copy link

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?

@danjac
Copy link

danjac commented Nov 19, 2022

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).

carltongibson added a commit to carltongibson/neapolitan that referenced this issue Apr 8, 2023
As per nedbat/django_coverage_plugin#74
An endblock on it's own line isn't measured as executed.
rebkwok added a commit to opensafely-core/airlock that referenced this issue Feb 12, 2024
django_coverage_plugin marks closing tags on their own lines as
uncovered
nedbat/django_coverage_plugin#74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants