Opened 2 years ago
Closed 2 years ago
#34230 closed Uncategorized (invalid)
Django templates shouldn't use a .html extension
Reported by: | Amin Shah Gilani | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 4.1 |
Severity: | Normal | Keywords: | django- |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello,
Only my second time filing a ticket so please go easy on me.
Django's templates use a .html
file extension. This is incorrect and causes issues:
- The files aren't HTML, they're template files
- Linters associated with
.html
extensions expect HTML and will attempt to format them - Tools that calculate metrics associated with HTML files won't recognize that the files aren't HTML
Ruby/Rails gets around this issue by using the .html.erb
(Embedded Ruby) extension, and there are comparable examples in other ecosystems like the .html.ejs
(Embedded JavaScript) templating language.
I believe Django can get around this with a similar terminating extension, e.g. .html.dtl
(Django Templating), or .html.django
, or even .html.djgo
.
Adopting an extension for the templating language will make things easier out of the box.
Change History (1)
comment:1 by , 2 years ago
Component: | Uncategorized → Template system |
---|---|
Resolution: | → invalid |
Status: | new → closed |
As far as I'm aware, that's not true. Django's template system allows you to use any extension that you want,
.txt
,.html
,.my_custom_exception
etc.