Skip to content

LinkWithAttributes

The LinkWithAttributes object represents a single link with attributes in the storefront.

classDiagram
  direction LR
  LinkWithAttributes --> Url
  LinkWithAttributes --> AttributesList
  AttributesList --> Attribute
  class LinkWithAttributes{
    string title
    Url url
    ?AttributesList attributes
  }
  class Url{
  }
  class AttributesList{
  }
  class Attribute{
  }

Properties

Attribute name Type Description
title string Title of the link.
url null|Url Reference to the Url object.
attributes null|AttributesList Reference to the AttributesList object.

Property Examples

title property

{{ link.title }}
example title

url property

{{ link.url }}
/link/to/something

attributes property

{% for attribute in link.attributes %}
    {% if attribute.value %}
        {{ attribute.name }}="{{ attribute.value }}"
    {% else %}
        {{ attribute.name }}
    {% endif %}
{% endfor %}
hreflang="pl"

Usage examples

source
<link rel="{{ link.title }}" href="{{ link.url.absolute }}"{% for attribute in link.attributes %}{% if attribute.value %} {{ attribute.name }}="{{ attribute.value }}"{% else %} {{ attribute.name }}{% endif %}{% endfor %} />
output
<link rel="alternate" href="https://www.shoper.pl" hreflang="pl" />