我在_includes/last_two_foo_posts.html
中使用以下代码显示最后两个标有“Foo”标签的Jekyll帖子的title
:
{% assign posts = site.tags.Foo %}
{% for post in posts limit:2 %}
{{ post.title }}
{% endfor %}
我想重构代码,以便我可以使用
调用include
{% include last_two_posts.html param="Foo" %}
Liquid是否有办法在{{ include.param }}
代码中为Foo
使用site.tags.Foo
之类的内容?
答案 0 :(得分:1)
{% assign posts = site.tags.[include.tag] %}
{% for post in posts limit: include.number %}
<p>{{ post.title }}</p>
{% endfor %}
{% include post_by_tag.html tag='Rails' number=3 %}
Et hop!