【发布时间】:2015-05-09 22:33:43
【问题描述】:
这是我想要完成的:
<ul class="site-nav__dropdown">
{% for childlink in linklists[child_list_handle].links %}
this - {% assign color_from_settings = 'settings.collection_color_' | append: forloop.index %}
used here - <li{% if childlink.active %} class="site-nav--active" {% else %} style="background-color: {{ color_from_settings }}" {% endif %}>
<a href="{{ childlink.url }}" class="site-nav__link">{{ childlink.title | escape }}</a>
</li>
{% endfor %}
</ul>
当它被渲染时,我得到:
background-color: settings.collection_color_1;
而不是从 settings_data.json 获取的实际颜色,如下所示:
{
"current": "Default",
"presets": {
"Default": {
...
"collection_color_1": "#9997c0",
"collection_color_2": "#8997b1",
"collection_color_3": "#7997a2",
"collection_color_4": "#699793",
"collection_color_5": "#599784",
"collection_color_6": "#499775",
"collection_color_7": "#399766",
"collection_color_8": "#299757",
"collection_color_9": "#199748",
"collection_color_10": "#099739"
}
}
}
有没有办法以编程方式完成此操作,还是我真的必须使用 ?
【问题讨论】: