icingadb-web/library/Icingadb/Widget/MarkdownText.php

29 lines
610 B
PHP
Raw Permalink Normal View History

2020-03-31 11:32:29 -04:00
<?php
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
namespace Icinga\Module\Icingadb\Widget;
2020-03-31 11:32:29 -04:00
use Icinga\Web\Helper\Markdown;
use ipl\Html\BaseHtmlElement;
use ipl\Html\DeferredText;
class MarkdownText extends BaseHtmlElement
{
protected $tag = 'section';
protected $defaultAttributes = ['class' => 'markdown'];
/**
* MarkdownText constructor.
*
* @param string $text
*/
public function __construct(string $text)
2020-03-31 11:32:29 -04:00
{
$this->add((new DeferredText(function () use ($text) {
return Markdown::text($text);
}))->setEscaped(true));
}
}