{# @var craft \craft\web\twig\variables\CraftVariable #} {# @var entry \craft\elements\Entry #} {# a-tag ------------------------------------------------------------ #} {# -- Set Defaults -- #} {% set defaults = { cn: 'a-tag', modifiers: [], customClasses: [], data: {}, js: null, link: null, text: null, } %} {# -- Merge Default with Options -- #} {% set opt = opt is defined ? defaults|merge(opt) : defaults %} {# -- Modul -- #} {% if opt.text %} {% set element = opt.link ? 'a' : 'span' %} <{{ element }} {{ opt.link ? 'href=' ~ opt.link }} class="{{ opt.cn }} {% for modifier in opt.modifiers %} {{ modifier | length ? ' ' ~ opt.cn ~ '--' ~ modifier }} {% endfor %} {% for customClass in opt.customClasses %} {{ customClass | length ? ' ' ~ customClass }} {% endfor %} {{ opt.js ? opt.cn|replace({ 'a-' : 'js-' }) : '' }}" {% for key, value in opt.data %} {{ 'data-' ~ key ~ '=' ~ value }} {% endfor %}> {% filter typogrify %}{{ opt.text }}{% endfilter %} {% endif %}