For loop, wrap every two posts in a div
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Basically, I am using Jekyll (which uses the Liquid templating language) and I am trying to write a for loop which wraps every two items in a div . This is my current loop: {% for post in site.posts %} {{ post.title }} {% endfor %} Which would output four posts like so: Title Title Title Title My desired output for four posts is: Title Title Title Title How can I accomplish this? 回答1: I know I'm late to the game but I found what I feel is a fairly elegant solution that doesn't feel hacky. With for loop's limit and offset params, we can