๐ Liquid Template Reference
Below are common Liquid concepts and examples. Use the "Try it out"
link to load it directly into LiquidTester
1. Simple Variable Output
Description: Outputs the values of input variables name
and lastname
.
JSON input:
Template:
Result:
2. Filter: Upcase
Description: Uses the Upcase
filter to print the variable name
in uppercase.
JSON input:
Template:
Result:
3. Date Formatting
Description: Formats a datetime using the Date
filter.
JSON input:
Template:
Result:
4. Looping Through a Collection
Description: Iterates over a list of products and prints their name and price. Utilizes unless forloop.last
to determine whether a comma should be placed at the end of the product.
JSON input:
Template:
Result:
5. If/Else Condition
Description: Shows a different message depending on the value of age
.
JSON input:
Template:
Result:
6. Chained Filters (Slugify Example)
Description: Trims whitespace, converts to lowercase, and replaces spaces with dashes - useful for creating slugs.
JSON input:
Template:
Result:
7. PEPPOL Invoice Transformation
Description: A practical example that transforms JSON data into an EN 16931 UBL Invoice 1.3.13 XML document also known as PEPPOL BIS Billing 3.0 using a Liquid template. This showcases advanced techniques such as loops, conditions, and handling of XML namespaces.
The input is invoice data in JSON format, and the template generates a fully compliant PEPPOL UBL XML invoice, extracting and formatting key details such as supplier info, invoice number, dates, totals, and line items.