Skip to main content

ValidRenderSnippetArgumentTypes

All arguments provided when rendering a snippet must match the respective parameter's type defined in that snippet's LiquidDoc. If the argument is a variable this check will always pass.


The following examples contain code snippets that either fail or pass this check. All examples refer to the following snippet with optional parameters.

snippets/example-snippet.liquid

{% doc %}
@param {string} [some_str]
@param {number} [some_num]
@param {boolean} [some_bool]
@param {object} [some_obj]
@param [some_untyped]
{% enddoc %}

In the following example, the snippet is being rendered with an incorrect type:

sections/section.liquid

{% render 'example-snippet', some_str: 1 %}

In the following example, all arguments passed into the snippet match the expected type:

sections/section.liquid

{% render 'example-snippet',
some_str: 'text',
some_num: 1,
some_bool: false,
some_obj: shop,
some_untyped: product
%}

NOTE: shop and product are global liquid variables

In the following example, an object is passed as a boolean argument since all Liquid objects can be truthy/falsey:

sections/section.liquid

{% render 'example-snippet', some_bool: product %}

In the following example, a variable is passed as an argument, which will always pass this check:

sections/section.liquid

{% assign some_var = 'text' %}
{% render 'example-snippet',
some_str: some_var,
some_num: some_var,
some_bool: some_var,
some_obj: some_var,
some_untyped: some_var
%}

The following example contains the default configuration for this check:

ValidRenderSnippetArgumentTypes:
enabled: true
severity: warning
ParameterDescription
enabledWhether this check is enabled.
severityThe severity of the check.

Anchor to Disabling this checkDisabling this check

Disabling this check isn't recommended.


Was this page helpful?