我正在尝试在其他 2 个模板中共享一个模板,如下所示:
_layouts/V2/post.slim
{% include V2/date_wrapper.html date_value=page.date %}
和
_includes/V2/footer/recent_posts.slim
| {% for post in site.posts limit: 5 %}
| <div class="w-bloglist-entry">
| <a class="w-bloglist-entry-link" href="{{ post.url }}">{{ post.title }}</a>
| <span class="w-bloglist-entry-date">
| <i class="fa fa-clock-o"></i>
| {% include V2/date_wrapper.html date_value=post.date %}
| </span>
| </div>
| {% endfor %}
这是共享模板:
_includes/V2/date_wrapper.html
{% assign d = include.date_value | date: "%-d" %}
{{ include.date_value | date: "%B" }}
{% case d %}
{% when '1' or '21' or '31' %}{{ d }}st,
{% when '2' or '22' %}{{ d }}nd,
{% when '3' or '23' %}{{ d }}rd,
{% else %}{{ d }}th,{% endcase %} {{ include.date_value | date: "%Y" }}
如果我只在帖子中使用模板进行设置,它可以工作,但是,无论我尝试什么,我似乎都无法让它在 for 循环的页脚中工作。错误是:
Liquid Exception: undefined method `data' for #<Jekyll::SlimPartialTag:0x007ffa549315b0> in _layouts/V2/post.slim
14:47:34 - ERROR - Jekyll build has failed
想法?这在 Jekyll 中可行吗?