Refine Jinja2 Template

I have a Jinja2 template that I would like to use, but cannot combine with exaggerating code. This question has been asked before, but there hasn't been an answer after almost two years, so maybe there is an answer.

<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 "prefix" this code:

<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 function of the code.

+3
python html jinja2


source to share


No one has answered this question yet

See similar questions:

36
Python: How to Pretty Print html to file
eleven
Sort by Jinja2 templates
0
Jinja2 parses boolean variables carefully

or similar:

257
Get length of list in jinja2 template
164
How do I format a date in Jinja2?
127
Passing HTML to Template using Flask / Jinja2
116
Jinja2 templated variable if None Object sets default value
97
Python jinja2 shorthand conditional
96
Call python function from jinja2
61
How to include HTML file in Jinja2 template?
27
Jinja2 escape syntax in jinja2 template
1
How to reference selection values ​​in Datastore model in create.html Jinja2 template in GAE-Python?
0
Jinja2 parses boolean variables carefully



All Articles
Loading...
X
Show
Funny
Dev
Pics