JSON datas

Render tag with the for parameter, using json datas for an array of objects.

output

Title: Balls get inside

Content: With a lot of pressure

Author: Barbara Streisand

Title: The intruder

Content: Got inside the house

Author: Bastien Vacherand

Title: When the sun goes down

Content: That's when the fun begins

Author: Mickael Jackson

input

{% render 'components/card' for multiple-objects as item %}

card.liquid

<article>
    <h4>Title: {{ item.title }}</h4>
    <p>Content: {{ item.content}}</p>
    <p>Author: {{ item.author }}</p>
</article>

multiple-objects.json

[
    {
        "title": "Balls get inside",
        "content": "With a lot of pressure",
        "author": "Barbara Streisand"
    },
    {
        "title": "The intruder",
        "content": "Got inside the house",
        "author": "Bastien Vacherand"
    },
    {
        "title": "When the sun goes down",
        "content": "That's when the fun begins",
        "author": "Mickael Jackson"
    }
]

In the example above, the template will be rendered once for each variant of the product, and the variant variable will hold a different product variant object for each iteration.

When using the for parameter, the forloop object is accessible within the rendered template.