Reputation: 14574
I have a snippet of code I include whenever I need to display a gallery.
<!-- _includes/gallery.md -->
{% assign items = {{include.data}} %}
{% for item in items -%}
{% assign src = item.path | prepend: "/assets/images/" | relative_url %}
[![{{item.alt}}]({{src}}){:.gallery-{{items.size}}}]({{src}})
{%- endfor %}
{:.text-center}
I can pass site.data
to populate the gallery.
{% include gallery.md data = site.data.index.themes %}
I have a template page which needs to display a gallery. I want to pass in site.data
as well.
<!-- _includes/create-new.md -->
Create a new {{include.type}}:
{% include gallery.md data = {{include.site_data}} %}
But when I try to pass in site.data
to the template page, I get an error.
{% include create-new.md type = "layout" site_data = site.data.index.layouts %}
How do you pass site.data
to includes within includes?
Upvotes: 0
Views: 207
Reputation: 5444
Simply pass it like any other data irrespective of whether nested within another include tag:
<!-- _includes/create-new.md -->
Create a new {{ include.type }}:
{% include gallery.md data = include.site_data %}
Upvotes: 1