jekyll变量,如果函数 [英] jekyll variables, if functions
本文介绍了jekyll变量,如果函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这样的东西不起作用? 我尝试过滤今年的所有帖子
Why is something like this not working ? i try to filter all posts from this year
<div class="tiles">
{% for post in site.categories.articles %}
{% capture pubyear %} {{ post.date | date: "%Y" }} {% endcapture %}
{% if pubyear == "2014" %}
{% include post-grid.html %}
{% endif %}
{% endfor %}
</div><!-- /.tiles -->
推荐答案
问题是它正在捕获带有一些空格的输出,因此它无法满足if条件,请删除这些空格,然后它应该可以工作
The problem is that it is capturing the output with some spaces in it, so it fails the if condition, remove those spaces and it should work
<div class="tiles">
{% for post in site.categories.articles %}
{% capture pubyear %}{{ post.date | date: "%Y" }}{% endcapture %}
{% if pubyear == "2014" %}
{% include post-grid.html %}
{% endif %}
{% endfor %}
</div>
这篇关于jekyll变量,如果函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文