电子邮件液体模板-拆分字符串并内联显示字符串[index]

问题描述 投票:0回答:1

我当前正在使用液体模板,并且我有一个带有管道定界符|的字符串。如何分割该字符串并显示我想要的特定字符串?

我有:

{{ type | split: "|"}}

(类型是一个包含“饼干|饼干”的变量)我不确定在哪里添加我需要的字符串的索引。

谢谢

email shopify html-email liquid liquid-template
1个回答
0
投票

{{ type | split: "|" | first }}代表Cookies

{{ type | split: "|" | last }} for 饼干

或按索引访问它:

{%- assign typeParts = type | split: "|" -%}

然后:{{ typeParts[0] }}用于Cookie{{ typeParts[1] }}(饼干)

© www.soinside.com 2019 - 2024. All rights reserved.