{% block content %}
{% for blog_dict in blogs|sort(reverse=True,attribute='date') if ((not file_name_filter) or blog_dict.filename==file_name_filter) and ((not category_filter) or blog_dict.category==category_filter) %}
<div id="post{{blog_dict.post_number}}-{{blog_dict.link_name}}">
{{blog_dict.date.strftime("%Y-%m-%d")}}
<a href="/posts/{{blog_dict.filename}}"><h1>{{blog_dict.heading}}</h1></a>
<!-- Place this tag where you want the +1 button to render -->
<div class="g-plusone" data-href="/posts/{{blog_dict.filename}}"></div>
{{blog_dict.post|safe}}
</div>
<br />
<br />
<br />
<img src="/images/page_divider.gif"><br />
{% endfor %}
{% endblock %}
正如你所看到的表情也越来越凌乱:
{% for blog_dict in blogs|sort(reverse=True,attribute='date') if ((not file_name_filter) or blog_dict.filename==file_name_filter) and ((not category_filter) or blog_dict.category==category_filter) %}
我尝试另一种选择是把两个嵌套如果在循环语句采取两个滤波器的照顾,但随后嵌套了较大。
什么是最优雅的?