Sha256: e49b86a3cee064e96048f6fd8968c3384b374a789ed9bad1f58b14834bd2040d

Contents?: true

Size: 1.79 KB

Versions: 23

Compression:

Stored size: 1.79 KB

Contents

# Encourage use of liquid tag for consecutive statements (LiquidTag)

Recommends using `{% liquid ... %}` if 4 or more consecutive liquid tags (`{% ... %}`) are found.

## Check Details

This check is aimed at eliminating repetitive tag markers (`{%` and `%}`) in theme files.

:-1: Example of **incorrect** code for this check:

```liquid
{% if collection.image.size != 0 %}
{%   assign collection_image = collection.image %}
{% elsif collection.products.first.size != 0 and collection.products.first.media != empty %}
{%   assign collection_image = collection.products.first.featured_media.preview_image %}
{% else %}
{%   assign collection_image = nil %}
{% endif %}
```

:+1: Example of **correct** code for this check:

```liquid
{%- liquid
  if collection.image.size != 0
    assign collection_image = collection.image
  elsif collection.products.first.size != 0 and collection.products.first.media != empty
    assign collection_image = collection.products.first.featured_media.preview_image
  else
    assign collection_image = nil
  endif
-%}
```

## Check Options

The default configuration for this check is the following:

```yaml
LiquidTag:
  enabled: true
  min_consecutive_statements: 5
```

### `min_consecutive_statements`

The `min_consecutive_statements` option (Default: `5`) determines the maximum (inclusive) number of consecutive statements before the check recommends a refactor.

## When Not To Use It

It's safe to disable this rule.

## Version

This check has been introduced in PlatformOS Check 0.0.1.

## Resources

- [`{% liquid %}` Tag Reference][liquid]
- [Rule Source][codesource]
- [Documentation Source][docsource]

[liquid]: https://documentation.platformos.com/api-reference/liquid/platformos-tags
[codesource]: /lib/platformos_check/checks/liquid_tag.rb
[docsource]: /docs/checks/liquid_tag.md

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
platformos-check-0.4.12 docs/checks/liquid_tag.md
platformos-check-0.4.11 docs/checks/liquid_tag.md
platformos-check-0.4.10 docs/checks/liquid_tag.md
platformos-check-0.4.9 docs/checks/liquid_tag.md
platformos-check-0.4.8 docs/checks/liquid_tag.md
platformos-check-0.4.7 docs/checks/liquid_tag.md
platformos-check-0.4.6 docs/checks/liquid_tag.md
platformos-check-0.4.5 docs/checks/liquid_tag.md
platformos-check-0.4.4 docs/checks/liquid_tag.md
platformos-check-0.4.3 docs/checks/liquid_tag.md
platformos-check-0.4.2 docs/checks/liquid_tag.md
platformos-check-0.4.1 docs/checks/liquid_tag.md
platformos-check-0.4.0 docs/checks/liquid_tag.md
platformos-check-0.3.3 docs/checks/liquid_tag.md
platformos-check-0.3.1 docs/checks/liquid_tag.md
platformos-check-0.3.0 docs/checks/liquid_tag.md
platformos-check-0.2.2 docs/checks/liquid_tag.md
platformos-check-0.2.1 docs/checks/liquid_tag.md
platformos-check-0.2.0 docs/checks/liquid_tag.md
platformos-check-0.1.0 docs/checks/liquid_tag.md