【发布时间】:2012-02-17 07:23:07
【问题描述】:
如果我在 Liquid 中有一个 for 循环(使用 Jekyll),我如何才能只定位偶数(或奇数)项?我试过了:
{% for item in site.posts %}
{% if forloop.index % 2 == 1 %}
但这似乎不起作用。我也试过:
(forloop.index % 2) == 1
和:
forloop.index - (forloop.index / 2 * 2) == 1
【问题讨论】: