{# @var craft \craft\web\twig\variables\CraftVariable #} {# @var entry \craft\elements\Entry #} {# Description of what this file is for @package baukasten @author David Hellmann [davidhellmann.com@gmail.com] m-pageTitle ------------------------------------------------------------ #} {# -- Set Defaults -- #} {% set defaults = { cn: 'm-pageTitle', modifiers: [], customClasses: [], data: {}, js: null, object: entry ?? null, text: null, size: 'h1', link: null } %} {# -- Merge Default with Options -- #} {% set opt = opt is defined ? defaults|merge(opt) : defaults %} {# -- Modul -- #} {% if opt.object or opt.text %} {% if opt.text %} {% set headline = opt.text %} {% elseif opt.object.entryCustomH1 ?? null and opt.object.entryCustomH1 | length %} {% set headline = opt.object.entryCustomH1 %} {% else %} {% set headline = opt.object.title %} {% endif %} <{{ opt.size }} 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({ 'm-' : 'js-' }) : '' }}" {% for key, value in opt.data %} {{ 'data-' ~ key ~ '=' ~ value }} {% endfor %}> {% if opt.link %} {% endif %} {{ headline | nl2br }} {% if opt.link %} {% endif %} {% endif %}