

Auto-Format HTML Templates in Django with VSCode
source link: https://knasmueller.net/auto-format-html-templates-in-django-with-vscode
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Auto-Format HTML Templates in Django with VSCode
Posted by Bernhard Knasmüller
October 4, 2021
Problem:
When writing HTML templates for the Django Python framework, you want to use Visual Studio Code’s auto formatting features. However, when you activate the auto-format functionality, VSCode complains that there is no formatter available for such HTML files:
“There is no formatter for ‘django-html’ files installed.”
Solution:
First, install the beautify
extension.
Then, open the settings.json by pressing SHIFT - CMD - P
and enter “Open Settings (JSON)”:
Next, add the following block to your settings.json
:
"files.associations": { "**/*.html": "html", "**/templates/**/*.html": "django-html", "**/templates/**/*": "django-txt", "**/requirements{/**,*}.{txt,in}": "pip-requirements" }, "emmet.includeLanguages": { "django-html": "html" }, "beautify.language": { "html": [ "htm", "html", "django-html" ] }
Save the changes and go back to your HTML template – you should now be able to format the HTML code automatically by pressing SHIFT - OPTION - F
.
Recommend
-
5
Unix time format in Azure Resource Manager templates The Unix time format is represented in seconds elapsed since 01.01.1970 UTC. So, it is different from the standard time format we are used to.Depending on the Azure service...
-
9
Creating a default DATETIME_FORMAT filter for django Friday, May 2, 2008 Here is a simple django template
-
9
Minimal Resume For PDF Export (premium resume template)Thankfully, there are several applications that allow you to create and easily export your resume to PDF format.
-
13
ESLint + VSCode: How to Format Your Code Using .eslintrc April 07, 2021I’ve gotten very used to having VSCode autoformat my file when I save. Usually, I use Prettier. But I joined a project that uses ESLint to manage...
-
12
How do I disable GoLang's auto-formatting on file save in VSCode? May 13 ・1 min read...
-
8
Syntax highlighting for template strings in F# VS Code extension that highlights HTML in F# interpolated strings with the following format. html $"""<h1>Hello World!</h1>""" You need to declar...
-
14
Auto format R code in RStudio advertisements Is there any possibilities for auto-formatting code in RStudio?
-
8
Vscode配置clang-Format的tabWidth 2019-03-27 14:03:58 code 约 407 字 预计阅读 1 分钟...
-
13
vscode C++ 开发之使用 clangd、C/C++、clang-format ...
-
11
The Power of Data: Annual Report Format Explained with Templates 20 Jul 2023 13 min read ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK