简体   繁体   English

如何动态地将阵列传递到液体过滤器?

[英]How to pass an array to liquid filters on the fly?

I have tried the following without success: 我尝试了以下操作,但未成功:

{{ 'foo', 'bar'   | join: ',' }}
{{ ('foo', 'bar') | join: ',' }}
{{ ['foo', 'bar'] | join: ',' }}

I really don't wanna have another line to pass the array into a variable then use it. 我真的不想再有一行将数组传递给变量然后使用它。

How can I fix this? 我怎样才能解决这个问题?

The Array needs to come from a Liquid Drop. 阵列需要来自液滴。 Liquid does not allow you to assign an Array. Liquid不允许您分配数组。

{% assign a = [1,2,3] %}

will NOT work. 无法正常工作。 So even on 2 lines it won't work. 因此,即使是两行也无法正常工作。

I don't understand your situation but it seems you can just do :) ;) : 我不了解您的情况,但看来您可以做到:);):

{{ 'foo,bar' }}

or maybe something like (one line also :)): 或类似的东西(也一行:)):

{{ '1|2|3'  | split:'|' | join:',' }}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM