Entity List filters are used to work with certain entitylist attribute values, and to help create entity list views.

current_sort

Given a sort expression, returns the current sort direction for a given attribute.

Code
{{ 'name ASC, createdon DESC' | current_sort: 'createdon' }}
Output
DESC

metafilters

Parses an entitylist filter_definition JSON value into filter option group objects.

metafilters can be optionally provided with a current attribute filter query and current entityview, allowing the returned filter objects to be flagged as either selected or unselected.

Code
{% assign filters = entitylist | metafilters: params.mf, entityview %}
{% if filters.size > 0 %}
  <ul id="entitylist-filters">
    {% for filter in filters %}
      <li class="entitylist-filter-option-group">
        {% if filter.selection_mode == 'Single' %}
          {% assign type = 'radio' %}
        {% else %}
          {% assign type = 'checkbox' %}
        {% endif %}
        <h4 class="entitylist-filter-option-group-label"
          data-filter-id="{{ filter.id | h }}">
          {{ filter.label | h }}
        </h4>
        <ul>
          {% for option in filter.options %}
            <li class="entitylist-filter-option">
              {% if option.type == 'text' %}
                <div class="input-group entitylist-filter-option-text">
                  <span class="input-group-addon">
                    <span class="fa fa-filter" aria-hidden="true"></span>
                  </span>
                  <input class="form-control"
                    type="text"
                    name="{{ filter.id | h }}"
                    value="{{ option.text | h }}" />
                </div>
              {% else %}
                <div class="{{ type | h }}">
                  <label>
                    <input
                      type="{{ type | h }}"
                      name="{{ filter.id | h }}"
                      value="{{ option.id | h }}"
                      {% if option.checked %}
                        checked="checked"
                        data-checked="true"{% endif %}
                      />
                    {{ option.label | h }}
                  </label>
                </div>
              {% endif %}
            </li>
          {% endfor %}
        </ul>
      </li>
    {% endfor %}
  </ul>
  <button class="btn btn-default" data-serialized-query="mf" data-target="#entitylist-filters">Apply Filters</button>
{% endif %}

reverse_sort

Given a sort direction, returns the opposite sort direction.

Code
<!-- Sort direction is not case-sensitive -->
{{ 'ASC' | reverse_sort }}
{{ 'desc' | reverse_sort }}
Output
DESC
ASC