request to add support for Jinja2 and Django template tags indention
See original GitHub issueI’m currently using vscode and have some extensions installed and some configuration for those extensions applied.
Django
by Baptiste Darthenay and Beautify
by HookyQR, are the extensions and this is the settings:
"files.associations": {
"**/*.html": "html",
"**/templates/**/*.html": "django-html", // this is provided by Django ext.
},
"beautify.language": {
"html": ["django-html"]
},
"[django-html]": {
"editor.defaultFormatter": "HookyQR.beautify",
}
it is very helpful since it will indent the html tags inside Django-templates but it doesn’t do anything with Jinja2 or Django-template syntax (which is really similar but not exactly jinja). I hope there would be a solution to have the indention for this syntax too. it currently looks like this:
<div class="card-data">
<ul class="list-unstyled">
<li class="comment-date font-small">
<i class="far fa-clock-o"></i>
{% if LANGUAGE_BIDI %}
{{ comment.created|to_jalali:'%H:%M %B %d, %Y' }}
{% else %}
{{ comment.created }}
{% endif %}
</li>
</ul>
</div>
imagine the ugly code when using nested template tags. thanks for your attention.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6
Top Results From Across the Web
Template Designer Documentation - Jinja
A template contains variables and/or expressions, which get replaced with values when a template is rendered; and tags, which control the logic of...
Read more >Jinja2 correctly indent included block - Stack Overflow
Good question. I believe Jinja2 does not do this. The main question you need to ask yourself is why you want the HTML...
Read more >rtts/djhtml: Django/Jinja template indenter - GitHub
DjHTML is a fully automatic template indenter that works with mixed HTML/CSS/Javascript templates that contain Django or Jinja template tags. It works similar ......
Read more >HTML indentation broken when Jinja tags are used : PY-11159
Attempting to run the code format while Jinja is set as the template language will not move the lis into the correct column...
Read more >jinja2 indentation with gg=G - Vi and Vim Stack Exchange
You will probably have to do this yourself, by copying the HTML indent file, and modify it so that it recognized Django-style blocks....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Zymonick hello. that indentation rule I pasted here was for vscode custom language extension, I added to
Django extension of Baptist-Dartenay
(sorry if I spelled it wrong) and there the rules worked but that was not complete as it worked just when I was typing the code but it couldn’t format on save or… anyway theHookyQR.beautify
is not maintained anymore is signed as deprecated. thedjlint
extension for vscode is working well and I’m using it.oh great, thank you very much for the very quick reply. I installed djilint and it works very well!