You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this a bug or me not understanding how djlint parses relative paths, but I can't get djlint to recognize jinja2 templates that are included via {% include 'relative_path/other_template.jinja2' %}.
How To Reproduce
I'm using djlint as a pre-commit hook. Here is my pre-commit-config.yaml:
The key here is that there is a <title> tag in this included template, and I have verified that it renders in the browser. We will see that djlint does not see this <title> tag when it is contained in the included template.
From the root directory if I run my pre-commit hook like this:
poetry run pre-commit run djlint-jinja --files app/templates/dummy.jinja2
I get this set of errors back from djlint:
app/templates/dummy.jinja2
───────────────────────────────────────────────────────────────────────────────
H016 2:0 Missing title tag in html. <html lang="en">
H030 2:0 Consider adding a meta description. <html lang="en">
H031 2:0 Consider adding meta keywords. <html lang="en">
Linted 1 file, found 3 errors.
This is unexpected since I have a <title> tag in "base/dummy_head.jinja2", the template I included in dummy.jinja2.
However, if I simply replace the line: {% include "base/dummy_head.jinja2" %} with the contents of that file in app/templates/dummy.jinja2 I see the H016 error go away.
I have tried replacing the relative path "base/dummy_head.jinja2" with the full path from the root directory of the project, but I get the same djlint errors.
Contents of .djlintrc/pyproject.toml [tool.djlint]
Not relevant since I am running djlint as a pre-commit hook.
The text was updated successfully, but these errors were encountered:
System Info
3.11
)v1.34.1
)Issue
I'm not sure if this a bug or me not understanding how djlint parses relative paths, but I can't get djlint to recognize jinja2 templates that are included via {% include 'relative_path/other_template.jinja2' %}.
How To Reproduce
I'm using djlint as a pre-commit hook. Here is my
pre-commit-config.yaml
:Let's say we have a project structure like this:
I am linting
app/templates/dummy.jinja2
whose contents are:And the file
app/templates/base/dummy_head.jinja2
has these contents:The key here is that there is a
<title>
tag in this included template, and I have verified that it renders in the browser. We will see that djlint does not see this<title>
tag when it is contained in the included template.From the root directory if I run my pre-commit hook like this:
I get this set of errors back from djlint:
This is unexpected since I have a
<title>
tag in"base/dummy_head.jinja2"
, the template I included indummy.jinja2
.However, if I simply replace the line:
{% include "base/dummy_head.jinja2" %}
with the contents of that file inapp/templates/dummy.jinja2
I see the H016 error go away.I have tried replacing the relative path
"base/dummy_head.jinja2"
with the full path from the root directory of the project, but I get the same djlint errors.Contents of .djlintrc/pyproject.toml [tool.djlint]
Not relevant since I am running djlint as a pre-commit hook.
The text was updated successfully, but these errors were encountered: