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


source to share





All Articles