Skip to main content

ValidContentForArgumentTypes

All arguments provided when rendering a static block must match the respective parameter's type defined in that block'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 block with optional parameters.

blocks/example-block.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 static block is being rendered with an incorrect type:

sections/section.liquid

{% content_for 'block', type: 'example-block', some_str: 1 %}

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

sections/section.liquid

{% content_for 'block',
type: 'example-block',
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

{% content_for 'block', type: 'example-block', 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' %}
{% content_for 'block',
type: 'example-block',
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:

ValidContentForArgumentTypes:
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?