Skip to content

Introduce snippet dependency annotation #114

@karreiro

Description

@karreiro

Are you seeking a solution to a specific problem? Let's delve into it.

Some Shopify Liquid assets, like snippets, depend on variables that are not defined in the global scope. Instead, these variables find their definition within the parent template.

This is about supporting a type annotation to declare those variables, so the UndefinedObject may rely on those annotations to understand the variables available in runtime for a given template. By doing so, we hope to create an intuitive interface definition for Liquid assets.

To illustrate a potential approach, consider the following code snippet. Please note that this is not the final syntax, but merely an example to help visualize the concept:

{% comment %}
  This snippet is designed to render product buy-buttons.
  It accepts several parameters:
  - product: {Object} Represents the product object.
  - block: {Object} Contains information about the block.
  - product_form_id: {String} Identifies the product form.
  - section_id: {String} Specifies the section to which this snippet belongs.
  - show_pickup_availability: {Boolean} Controls whether pickup availability is rendered. If set to true, pickup availability is displayed; if false, it's not (this is optional).

  Here's an example of how you might use it:
  {% render 'buy-buttons', block: block, product: product, product_form_id: product_form_id, section_id: section.id, show_pickup_availability: true %}
{% endcomment %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions