mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-06 20:48:40 +00:00
add custom tags
This commit is contained in:
parent
a9745c2f1c
commit
ec210f8b8e
|
|
@ -80,6 +80,14 @@ final class Head implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
private array $script = [];
|
private array $script = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tags bound to this page instance.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private array $tags = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
@ -91,7 +99,7 @@ final class Head implements RenderableInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set page title.
|
* Add asset.
|
||||||
*
|
*
|
||||||
* @param int $type Asset type
|
* @param int $type Asset type
|
||||||
* @param string $uri Asset uri
|
* @param string $uri Asset uri
|
||||||
|
|
@ -105,6 +113,21 @@ final class Head implements RenderableInterface
|
||||||
$this->assets[$uri] = ['type' => $type, 'attributes' => $attributes];
|
$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.
|
* Set page language.
|
||||||
*
|
*
|
||||||
|
|
@ -296,4 +319,27 @@ final class Head implements RenderableInterface
|
||||||
|
|
||||||
return $rendered;
|
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'] . '</' . $tag['tag'] . '>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rendered;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user