diff --git a/Model/Html/Head.php b/Model/Html/Head.php index 07cb0482b..885e6db3c 100755 --- a/Model/Html/Head.php +++ b/Model/Html/Head.php @@ -80,6 +80,14 @@ final class Head implements RenderableInterface */ private array $script = []; + /** + * Tags bound to this page instance. + * + * @var array + * @since 1.0.0 + */ + private array $tags = []; + /** * Constructor. * @@ -91,7 +99,7 @@ final class Head implements RenderableInterface } /** - * Set page title. + * Add asset. * * @param int $type Asset type * @param string $uri Asset uri @@ -105,6 +113,21 @@ final class Head implements RenderableInterface $this->assets[$uri] = ['type' => $type, 'attributes' => $attributes]; } + /** + * Add tag. + * + * @param int $type Asset type + * @param string $uri Asset uri + * + * @return void + * + * @since 1.0.0 + */ + public function addTag(string $tag, string $content, array $attributes = []) : void + { + $this->tags[] = ['tag' => $tag, 'content' => $content, 'attributes' => $attributes]; + } + /** * Set page language. * @@ -296,4 +319,27 @@ final class Head implements RenderableInterface return $rendered; } + + /** + * Render tags. + * + * @return string + * + * @since 1.0.0 + */ + public function renderTags() : string + { + $rendered = ''; + foreach ($this->tags as $tag) { + $rendered .= '<' . $tag['tag']; + + foreach ($tag['attributes'] as $key => $attribute) { + $rendered .= ' ' . $key . '="' . $attribute . '"'; + } + + $rendered .= '>' . $tag['content'] . ''; + } + + return $rendered; + } }