Jekyll-赋值前评估字符串

 收藏

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

此代码仅打印以下内容:

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.

回复