【发布时间】:2011-05-03 00:16:00
【问题描述】:
我正在尝试使用 jinja2 模板语言返回我的帖子列表中的最后 n(比如 5)个帖子:
{% for recent in site.posts|reverse|slice(5) %}
{% for post in recent %}
<li> <a href="/{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endfor %}
不过,这将返回整个列表。如何去除第一个或最后 n 个元素?
【问题讨论】: