/sublime_djhtml

DjHTML plugin for Sublime Text

Primary LanguagePythonMIT LicenseMIT

Sublime DjHTML

A plugin for Sublime Text that integrates DjHTML to provide auto-indentation for Django/Jinja templates.

Requirements: Sublime Text 4

Installation

This plugin can be cloned into the Packages/ directory of Sublime Text:

  1. Find the local directory (Preferences -> Browse Packages).

  2. Clone the repo:

git clone https://github.com/jordaneremieff/sublime_djhtml

Usage

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:

Screen Shot 2021-06-06 at 3 11 29 pm

Running the auto-indent command will process the current file using DjHTML and update the editor directly:

Screen Shot 2021-06-06 at 3 12 07 pm

Settings

  • 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.