Remove unnecessary whitespace from Jinja rendered template

前端 未结 2 1836
梦毁少年i
梦毁少年i 2020-12-01 01:14

I\'m using curl to watch the output of my web app. When Flask and Jinja render templates, there\'s a lot of unnecessary white space in the output. It seems to

2条回答
  •  Happy的楠姐
    2020-12-01 01:57

    To collapse whitespace before and after a block:

    {%- if form.message -%} //trims before
       {{ form.message }}
    {%- endif -%} // trims after
    

提交回复
热议问题