davidwarrington / liquid-community-standards

1 stars 0 forks source link

Proposal: Use numbers to identify repeated options/groups of settings #5

Open davidwarrington opened 3 years ago

davidwarrington commented 3 years ago

Using numbers to differentiate between repeated options or groups of schema settings makes it easy to implement loops to access them.

Non-numerical alternatives, such as first and second, top and bottom, or left and right should be avoided if possible because they are more difficult to use inside a loop. In some cases, such as with left and right, they should also be avoided because they are not infinitely extendable.

Example

[
    {
        "label": "Title 1",
        "id": "title_1",
        "type": "text"
    },
    {
        "label": "Product 1",
        "id": "product_1",
        "type": "product"
    },
    {
        "label": "Link 1 Text",
        "id": "link_1_text",
        "type": "text"
    },
    {
        "label": "Link 1 URL",
        "id": "link_1_url",
        "type": "url"
    },
    {
        "label": "Title 2",
        "id": "title_2",
        "type": "text"
    },
    {
        "label": "Product 2",
        "id": "product_2",
        "type": "product"
    },
    {
        "label": "Link 2 Text",
        "id": "link_2_text",
        "type": "text"
    },
    {
        "label": "Link 2 URL",
        "id": "link_2_url",
        "type": "url"
    },
    {
        "label": "Title 3",
        "id": "title_3",
        "type": "text"
    },
    {
        "label": "Product 3",
        "id": "product_3",
        "type": "product"
    },
    {
        "label": "Link 3 Text",
        "id": "link_3_text",
        "type": "text"
    },
    {
        "label": "Link 3 URL",
        "id": "link_3_url",
        "type": "url"
    }
]