Shopify的流动语言,使用可重复字段

问题描述

我们正在为Shopify使用高级自定义字段插件,并且我正在使用可重复字段在Google Map上创建标记,因此我需要构建一个如下所示的JS数据数组:

['Popup text',lat,lang]

因此,当使用Liquid语言和可重复字段时,完整的代码如下所示:

{% for name in page.Metafields.markers.name %}
    {% assign name_index = forloop.index %}
    {% for lang in page.Metafields.markers.lang %}
        {% assign lang_index = forloop.index %}
        {% if name_index == lang_index %}
            ['{{name}}',{{lang}},{% endif %}
    {% endfor %}
    {% for lat in page.Metafields.markers.lat %}
        {% assign lat_index = forloop.index %}
        {% if name_index == lat_index %}
            {{lat}},4],{% endif %}
    {% endfor %}
{% endfor %}

这是“高级自定义字段”向我推荐的方式,但是我个人觉得这很糟糕,尤其是当我需要创建一个包含10个子字段的可重复字段时-我真的必须创建一个循环对于每个领域都这样?有没有更好/更清洁,更易读的方式来做到这一点?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)