Reputation: 7627
I need to capture a string into a variable tag
, then use this variable in site.tags.tag
. The code is:
{% capture tag %}programming{% endcapture %}
{{ tag }}
{%- assign titles = site.tags.tag | map: "title" -%}
{{ titles }}
This code only prints prints:
programming
But if I replace site.tags.tag
with either site.tags.programming
or site.tags.'programming'
I get the desired output:
programming
title1 title2
Is there a way to evaluate the variable tag
before the assignment? After reading a similar question I tried site.tags.{{tag}}
but it didn't work.
Upvotes: 1
Views: 180