jekyll shared template different parameters
Asked Answered
W

0

1

I am trying to share a single template in 2 other templates as follows:

_layouts/V2/post.slim
{% include V2/date_wrapper.html date_value=page.date %}

and

_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 %}

This is the shared template:

_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 %}&nbsp;{{ include.date_value | date: "%Y" }}

If I set this up using the template only in the post it works, however, no matter what I try I can not seem to get this to work in the footer in the for loop. The error is:

  Liquid Exception: undefined method `data' for #<Jekyll::SlimPartialTag:0x007ffa549315b0> in _layouts/V2/post.slim
14:47:34 - ERROR - Jekyll build has failed

Thoughts? Is this possible in Jekyll?

Withindoors answered 29/3, 2014 at 21:51 Comment(3)
Have you got a repo that shows this happening? I tried putting your code blocks in a new Jekyll project and it works for me. Happy to help debug if I can get it to happen.Constantine
@DavidHutchison odd, this is not a public repo sorry. Were you use slim templates as well?Withindoors
My default template wasn't, but the other files were just as you have shown.Constantine

© 2022 - 2024 — McMap. All rights reserved.