xref: /dokuwiki/inc/Form/TagElement.php (revision 90fb952c4c30c09c8446076ba05991c89a3f0b01)
164744a10SAndreas Gohr<?php
29d01c1d9SSatoshi Sahara
364744a10SAndreas Gohrnamespace dokuwiki\Form;
464744a10SAndreas Gohr
564744a10SAndreas Gohr/**
664744a10SAndreas Gohr * Class TagElement
764744a10SAndreas Gohr *
864744a10SAndreas Gohr * Creates a self closing HTML tag
964744a10SAndreas Gohr *
1064744a10SAndreas Gohr * @package dokuwiki\Form
1164744a10SAndreas Gohr */
129d01c1d9SSatoshi Saharaclass TagElement extends ValueElement
139d01c1d9SSatoshi Sahara{
1464744a10SAndreas Gohr    /**
1564744a10SAndreas Gohr     * @param string $tag
1664744a10SAndreas Gohr     * @param array $attributes
1764744a10SAndreas Gohr     */
18*6fd0861fSAndreas Gohr    public function __construct($tag, $attributes = [])
199d01c1d9SSatoshi Sahara    {
2064744a10SAndreas Gohr        parent::__construct('tag', $tag, $attributes);
2164744a10SAndreas Gohr    }
2264744a10SAndreas Gohr
2364744a10SAndreas Gohr    /**
2464744a10SAndreas Gohr     * The HTML representation of this element
2564744a10SAndreas Gohr     *
2664744a10SAndreas Gohr     * @return string
2764744a10SAndreas Gohr     */
289d01c1d9SSatoshi Sahara    public function toHTML()
299d01c1d9SSatoshi Sahara    {
3064744a10SAndreas Gohr        return '<' . $this->val() . ' ' . buildAttributes($this->attrs()) . ' />';
3164744a10SAndreas Gohr    }
3264744a10SAndreas Gohr}
33