Django Template: Toggle auto wrap/unwrap Django tags
Enable/disable automatic wrapping
Configuration
Setting
Type
Default
Description
djangoTemplateExtension.enableFormatting
boolean
true
Enable formatting for files in template folders
djangoTemplateExtension.templateFolderNames
array
["templates", "template"]
Folder names to be recognized as template folders
djangoTemplateExtension.autoDetectPythonProject
boolean
true
Only activate formatting when inside a Python project
djangoTemplateExtension.wrapDjangoTagsInComments
boolean
true
Auto wrap Django tags with /* */ on open and unwrap on save for TS/JS files
Installation
From VS Code Marketplace
Open VS Code
Go to Extensions (Ctrl+Shift+X)
Search for "Django Jinja Template Support"
Click Install
From VSIX
Download the .vsix file from the releases page
Open VS Code
Go to Extensions (Ctrl+Shift+X)
Click the ... menu and select "Install from VSIX..."
Select the downloaded file
Usage
HTML Templates
Files with .djhtml, .django, .jinja, .jinja2, or .j2 extensions are automatically recognized as Django HTML templates. For regular .html files in template folders, use the "Set as Django/Jinja HTML" command or right-click menu option.
TypeScript/JavaScript Templates
When you open a TypeScript or JavaScript file containing Django template tags:
The extension automatically wraps template tags with /* */ comments
The /* and */ markers are visually hidden
When you save, the comment wrappers are removed
After saving, they are re-applied for continued editing
Formatting
Use the standard VS Code format command (Shift+Alt+F) to format your template files. The extension will preserve Django/Jinja template tags while formatting the surrounding code.
Known Limitations
Document Dirty State: When opening TS/JS files with Django tags, the document will be marked as modified due to the automatic wrapping. This is a limitation of the VS Code API.
Comment Markers Visibility: The /* */ comment markers are rendered nearly invisible (15% opacity, condensed spacing) but can still be seen on close inspection and selected with keyboard navigation.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.