I have a Jinja2 template that I'd like to use, but can't in conjunction with prettifying the code. This question has been asked before, but that hasn't had an answer in almost 2 years, so perhaps there's an answer out there now.
<select id="example-getting-started" name="test" multiple="multiple">
{% for k in pizza_dict %}
<option value="{{ k }}" {% if pizza_dict[k] %}selected{% endif %}>{{ k }}</option>
{% endfor %}
</select>
BeautifulSoup and lxml will "prettify" this code to:
<select id="example-getting-started" multiple="multiple" name="test">
{% for k in pizza_dict %}
<option endif="" if="" pizza_dict="" value="{{ k }}"> {{ k }} </option>
{% endfor %} </select>
which will destroy the code's function.
Recently I was seeking for some tool for autoformatting and found the VSOT: https://pypi.org/project/vsot/
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