Skip to content

list_description

The list_description macro is used to render a description of a list.

Definition

{% list_description(content, options) %}

Input parameters

description

string represents a text content of the description element.

options (optional)

object represents an object of list description options

Option key Type Default Required Description
options.cssClasses string "" yes A list of styling classes that will be added to the description
options.page int none no The current page number. When provided, the description is only displayed on page 1.
options.productList ProductsList none no Deprecated fallback for determining the current page when options.page is not provided. Prefer options.page — it avoids an extra products query.

Example

Here is an example of a basic list description

{% from "@macros/list_description.twig" import list_description %}

{{ list_description('Example description') }}

Example

Here is an example of a list description with additional styling classes.

{{ list_description('Example description', {
    cssClasses: 'color_success-500 font_bold'
}) }}

Macro source code

{% macro list_description(description, options) %}
    {% set shouldDisplayDescription = options.page is defined
        ? options.page == 1
        : (options.productList is defined ? options.productList.page == 1 : true) %}

    {% if description and shouldDisplayDescription %}
        <div class="section-description {{ options.cssClasses }}">{{ description | raw }}</div>
    {% endif %}
{% endmacro %}