django template auto format tool?

706 views
Skip to first unread message

Abraham Varricatt

unread,
Dec 13, 2014, 9:53:56 PM12/13/14
to django...@googlegroups.com
Hello,

Is there any command-line based tool which would let one auto-format Django template files? Ideally, the tool should also be used to format HTML, CSS and .JS files too. 

I've recently inherited a bad-looking code base and want to clean it up. Have heard of the PEP8 autoformatter, but that just works for Python files, right?

-Abraham V.

Jose Regalado

unread,
Dec 14, 2014, 9:47:54 AM12/14/14
to django...@googlegroups.com
Install vim-autoformat plugin
https://github.com/Chiel92/vim-autoformat

install
sudo apt-get install python-autopep8 pep8 node nodejs

sudo npm install -g js-beautify

try:

1. create a vim file and put insde file:

:Autoformat python
:wq

save and name it: indent.vim

2 now:
vim -s indent.vim my_python_file.py

Now, for python works fine, but for html, I not yet test.
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6ce7098d-5ab0-4223-8488-35f6688adc9f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
José Luis Regalado
bashman
Linux User nº 280381
WhatsApp / Telegram +58 416 1705119

Mario Gudelj

unread,
Dec 14, 2014, 4:54:30 PM12/14/14
to django...@googlegroups.com

PyCharm ide does a great job for all those file types.

Abraham Varricatt

unread,
Dec 15, 2014, 12:34:15 PM12/15/14
to django...@googlegroups.com
@José Luis Regalado,

The vim idea is interesting, but I don't think too many developers can be convinced to open a file in a different editor just to format it. 

somecallitblues ,

Same reasoning. I'm using Pycharm myself, but for a mixed-editor/IDE team, I need a different tool to standardize on. 

And speaking of Pycharm, it acts really weird for some Django templates. It doesn't format multi-line comments. Which, might be for the best, but another issue is that the editor still highlights the code within! It's intelligent enough to recognize a comment, but feels the need to color it anyway?!?

-Abraham V.

Collin Anderson

unread,
Dec 17, 2014, 8:45:26 AM12/17/14
to django...@googlegroups.com
Hi Abraham,

If you made a took, I'd use it. :)

Collin

Abraham Varricatt

unread,
Dec 17, 2014, 9:38:29 AM12/17/14
to django...@googlegroups.com
Ha, ha. :D

I'm no expert. I need the tool myself to learn a lot of this stuff.

-Abraham V.


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/FOnYD1XMWRo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages