I have recently switched to Visual Studio Code (previously used PyCharm) and am now facing a formatting problem.
With the following example html:
{% extends 'base.html' %}
{% block body %}
{{ super() }}
<div>Something</div>
{% endblock%}
after saving (I have turned on formatOnSave) I get the following:
{% extends 'base.html' %}{% block body %}{{ super() }}
<div>Something</div>{% endblock%}
I am using the editorconfig plugin and have stayed with the default user settings.
How can I configure VSC to not force Jinja blocks to be on a single line?
Get it now. This extension adds language colorization support for the Jinja template language to VS Code. First, you will need to install Visual Studio Code 0.10. In the command palette ( cmd-shift-p) select Install Extension and choose Jinja.
This post is part of a series called Templating With Jinja2 in Flask . Jinja2 is a template engine written in pure Python. It provides a Django -inspired non-XML syntax but supports inline expressions and an optional sandboxed environment. It is small but fast, apart from being an easy-to-use standalone template engine.
Flask project templates are included with all earlier versions of Python Tools for Visual Studio, though details may differ from what's discussed in this tutorial. Python development is not presently supported in Visual Studio for Mac. On Mac and Linux, use the Python extension in Visual Studio Code.
At the insertion point in the "title" block, write Home, and in the "content" block, write <p>Home page for the Visual Studio Code Flask tutorial.</p>, then save the file. These lines are the only unique parts of the extended page template:
There's a known issue with trailing spaces.
You might try another extension dedicated to jinja: https://github.com/wholroyd/vscode-jinja
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With