'Prettier and Flask for Python in VS Code
I use VS Code and typically code in python and have been learning flask recently. This involves writing HTML etc. I have been using black to format my .py files and have been using Prettier for my other files. Is there a way to modify how prettier formats code blocks in HTML? For example, I find the following code rather unreadable, but this is how prettier is formatting it:
<div>
{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %}
<div>{{ category }}, {{ message }}</div>
{% endfor %} {% endif %} {% endwith %}
</div>
I'd rather it looks something like this:
<div>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="row">
{{ category }}, {{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
</div>
Can I change settings or would you recommend a different formatter? Thanks and here are my setting for the workspace.
{
"python.formatting.provider": "black",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[python]": {
"editor.defaultFormatter": "ms-python.python"
},
"prettier.useTabs": true
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
