rtts / djhtml

Django/Jinja template indenter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add spaces for template variables

Thutmose3 opened this issue · comments

Hi,

Could we add spaces to template variables?

initial:
{{book_title}}

end:
{{ book_title }}

The Django project / Django documentation adds spaces to template variables.

Thanks for your suggestion, but that would be reformatting, not indenting. From the README:

DjHTML is an indenter and not a formatter: it will only add/remove whitespace at the beginning of lines.

I see, thanks for your response.

What's the reason for not making djhtml a formatter as well? Too dangerous, risky, intrusive?

All those things, but also complexity. Currently, DjHTML parses all source text into only 6 types of tokens. In order to support language-specific formatting, it would need separate parsers for HTML/CSS/JS.

If you want auto-formatting and not just auto-indenting, you should have a look ad djLint, which does exactly that. As you may imagine though, it's a lot less lightweight as DjHTML, which I'm trying to keep as simple as possible.

Ok, that makes sense. I'll have a look at that project as well. Thanks!