0
votes

Following template with any array as content:

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

Produces this output in visual studio code, and is in line with documentation:

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

(I added space instead of new line for readabillity)

Running the same template on azure logic app will produce this output

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

Are there any other ways of achieving the same output using Liquid templates, without modulo? Seems like the | might be an issue,

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

doesnt seem to work either, but

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

works fine. However I am not sure how to use modulo in this way.

1

1 Answers

3
votes

I believe modulo should be Modulo (the capital 'M')

For Liquid Templates, Logic Apps use the DotLiquid library configured with the C# naming convention (refer this) requiring filter names to be capitalized.

This is also mentioned in a note in the Logic Apps docs for Transforming JSON.

Basically, the filters will have to be like this compared to the original ruby ones

  • at_least becomes AtLeast
  • plus becomes Plus

UPDATE: Not sure if parenthesis are valid in liquid but I had to remove them for Logic Apps

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