mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Add some useful renderables
This commit is contained in:
parent
c852b487b4
commit
072f91df47
47
src/Html/Renderables/Container.php
Normal file
47
src/Html/Renderables/Container.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Erusev\Parsedown\Html\Renderables;
|
||||
|
||||
use Erusev\Parsedown\Html\Renderable;
|
||||
|
||||
final class Container implements Renderable
|
||||
{
|
||||
use CanonicalStateRenderable;
|
||||
|
||||
/** @var Renderable[] */
|
||||
private $Contents;
|
||||
|
||||
/**
|
||||
* @param Renderable[] $Contents
|
||||
*/
|
||||
public function __construct($Contents)
|
||||
{
|
||||
$this->Contents = $Contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Renderable[]
|
||||
*/
|
||||
public function contents()
|
||||
{
|
||||
return $this->Contents;
|
||||
}
|
||||
|
||||
|
||||
/** @return string */
|
||||
public function getHtml()
|
||||
{
|
||||
return \array_reduce(
|
||||
$this->Contents,
|
||||
/**
|
||||
* @param string $html
|
||||
* @param Renderable $Renderable
|
||||
* @return string
|
||||
*/
|
||||
function ($html, Renderable $Renderable) {
|
||||
return $html . $Renderable->getHtml();
|
||||
},
|
||||
''
|
||||
);
|
||||
}
|
||||
}
|
20
src/Html/Renderables/Invisible.php
Normal file
20
src/Html/Renderables/Invisible.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Erusev\Parsedown\Html\Renderables;
|
||||
|
||||
use Erusev\Parsedown\Html\Renderable;
|
||||
|
||||
final class Invisible implements Renderable
|
||||
{
|
||||
use CanonicalStateRenderable;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function getHtml()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
27
src/Html/Renderables/RawHtml.php
Normal file
27
src/Html/Renderables/RawHtml.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Erusev\Parsedown\Html\Renderables;
|
||||
|
||||
use Erusev\Parsedown\Html\Renderable;
|
||||
|
||||
final class RawHtml implements Renderable
|
||||
{
|
||||
use CanonicalStateRenderable;
|
||||
|
||||
/** @var string */
|
||||
private $html;
|
||||
|
||||
/**
|
||||
* @param string $html
|
||||
*/
|
||||
public function __construct($html = '')
|
||||
{
|
||||
$this->html = $html;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function getHtml()
|
||||
{
|
||||
return $this->html;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user