Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format django template in Sublime Text

How can one format django template in Sublime Text. My template consists of:

  1. HTML (django template language with {{ variable }} and {% stuff %})
  2. javascript

Is there a way to get same kind of formatting PyCharm provides?

like image 645
Vladimir Nani Avatar asked Jun 20 '13 16:06

Vladimir Nani


People also ask

Can I use Sublime Text for Django?

If you're looking for a Django-specific plugin for Sublime Text I can recommend Djaneiro. Its main features are adding: syntax highlighting for Django HTML templates; and. code completion snippets for Django HTML templates and Python files.

How do I create a Django template?

To configure the Django template system, go to the settings.py file and update the DIRS to the path of the templates folder. Generally, the templates folder is created and kept in the sample directory where manage.py lives. This templates folder contains all the templates you will create in different Django Apps.

What does {% %} mean in Django?

{% %} and {{ }} are part of Django templating language. They are used to pass the variables from views to template. {% %} is basically used when you have an expression and are called tags while {{ }} is used to simply access the variable.

Is Django template Jinja?

The Django template language doesn't have an equivalent of Jinja2 tests.


2 Answers

A couple different things:

Djanerio has a nice set of auto-completion and color schemes specific to Django. Check out their README file to see the list of available substitutions

JSFormat is also great for javascript in ST2, for your templates

Colorpicker offers a generic css color sheet that you can tinker with. This comes in handy for things all of the above doesn't pick up on.

like image 51
JcKelley Avatar answered Oct 17 '22 22:10

JcKelley


This package should help: https://github.com/squ1b3r/Djaneiro

Here are some tips on install: How to install plugins to Sublime Text 2 editor?

like image 18
Shaun Singh Avatar answered Oct 17 '22 20:10

Shaun Singh