【问题标题】:Modulo not working on Liquid templates in Logic App, but works locallyModulo 不适用于 Logic App 中的 Liquid 模板,但可以在本地工作
【发布时间】:2019-04-10 13:58:19
【问题描述】:

以任意数组为内容的以下模板:

{%- for datapoint in content -%}
{%- assign breaker = (forloop.index | modulo: 4) -%}
{{breaker}}
{% if breaker == 0 %};
{% endif %}
{%- endfor -%}

在 Visual Studio 代码中生成此输出,并且符合文档:

1 2 3 0 1 2 3 0 1 2 3 0

(为了便于阅读,我添加了空格而不是换行)

在 azure logic app 上运行相同的模板会产生这个输出

1 2 3 4 5 6 7 8 9 10 11 12

有没有其他方法可以使用 Liquid 模板实现相同的输出,无需模数?好像|可能是个问题,

{%- assign arraysize = content | size -%}

似乎也不起作用,但是

{%- assign arraysize = content.size -%}

工作正常。但是我不确定如何以这种方式使用模数。

【问题讨论】:

    标签: liquid azure-logic-apps


    【解决方案1】:

    我认为modulo 应该是Modulo(大写“M”)

    对于 Liquid 模板,逻辑应用使用 DotLiquid 库,该库配置了 C# 命名约定(请参阅 this),要求过滤器名称大写。

    Transforming JSON 的逻辑应用文档中的注释中也提到了这一点。

    基本上,与原来的 ruby​​ 相比,过滤器必须是这样的

    • at_least 变为 AtLeast
    • plus 变为 Plus

    更新:不确定括号在液体中是否有效,但我必须为逻辑应用删除它们

    {%- for datapoint in content -%}
    {%- assign breaker = forloop.index | Modulo: 4 -%}
    {{ breaker }}
    {%- endfor -%}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多