Skip to content
LambogeniusDocs

Compose using Liquid for Azure Logic Apps

Templates

Deployed and inline templates, partials, template folders, whitespace, filters and ToJson.

Service provider/serviceProviders/lamboLiquidComposeOperation ComposeLiquid, shown in the designer as Compose using Liquid.

Deployed templates

Deployed templates live in the Logic App's Artifacts/LiquidTemplates folder (or LiquidCompose__TemplateRoot) and are deployed with the app. A connection's templateFolder is added to the path, so two connections over one folder, with templateFolder v1 and v2, let a workflow move to a new template version by changing connectionName.

Partials

{% comment %} Artifacts/LiquidTemplates/invoice.liquid {% endcomment %}
{% include 'partials/address.liquid' with content.billTo %}
{% for line in content.lines %}{% include 'partials/line.liquid' with line %}{% endfor %}

{% comment %} Artifacts/LiquidTemplates/partials/address.liquid: the value is bound as "address" {% endcomment %}
{{ address.name | Escape }}<br>{{ address.city | Escape }}
  • Literal paths only, relative to the template folder, up to 32 partials and 8 levels deep. Include cycles fail with TemplateSyntaxError.
  • The value is bound under the file name without its extension: partials/line.liquid sees line.
  • Inline templates (templateSource: inline) cannot include partials.

Whitespace

In text mode, every space and line break in the template reaches the output. A dash on the right of a tag (-%}) removes the whitespace and line break after it; a dash on the left does not remove the line break before it. Put tags at the end of the line they close:

{% for line in content.lines -%}
{{ line.sku }},{{ line.quantity }}
{% endfor -%}

For CRLF line endings, pass "\r\n" as a parameter and write {{ parameters.newline }}.

Filters

  • C# casing: Upcase, Default, Join, Size, Date, Plus, Times, DividedBy, Round. A lowercase or misspelled filter fails with UnknownFilter instead of being ignored.
  • Loop properties stay lowercase: forloop.index, forloop.last.
  • Numbers keep their exact decimal value, in the invariant culture. Date converts timestamps with an offset to the host's time zone (UTC on App Service) before formatting.
  • contains tests text. It doesn't find an item in an array that came from JSON: join the array first, as sample 08 shows.
  • Not supported: increment, decrement, and for … else.

JSON output and ToJson

Write every value as {{ value | ToJson }}, never "{{ value }}", which breaks on the first quote, backslash or line break. ToJson writes strings escaped, numbers exactly as they arrived, null for null and missing values, and arrays and objects as JSON. Separate loop items with {% unless forloop.last %},{% endunless %}.

In JSON mode the action checks the output: exactly one value, no duplicate keys, no trailing text. Anything else fails with InvalidOutputJson.