A plugin for Sublime Text that integrates DjHTML to provide auto-indentation for Django/Jinja templates.
Requirements: Sublime Text 4
This plugin can be cloned into the Packages/
directory of Sublime Text:
-
Find the local directory (
Preferences -> Browse Packages
). -
Clone the repo:
git clone https://github.com/jordaneremieff/sublime_djhtml
The auto-indent command can be applied in a different few ways:
- From the Command Palette by selecting
DjHTML: Indent File
- Using a keyboard shortcut (default
ctrl + shift + i
) - Configuring the
indent_on_save
setting (see settings section below)
As an example, consider a template that looks like this:
Running the auto-indent command will process the current file using DjHTML and update the editor directly:
-
tabwidth
(default=4
):The number of spaces used in indentation.
-
indent_on_save
(default=false
)Run indentation automatically on file save.
-
enabled_syntax
(default=["Packages/HTML/HTML.sublime-syntax", "Packages/Djaneiro/Syntaxes/HTML (Django).tmLanguage"]
)A list of file syntax definitions eligible for auto-indentation when
indent_on_save
is enabled.
If you encounter any problems, please open an issue.