Trait Yiisoft\Html\Tag\Base\TagContentTrait
Adds functionality for processing with tag content.
Public Methods
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| generateContent() | Yiisoft\Html\Tag\Base\TagContentTrait |
Method Details
| public Yiisoft\Html\Tag\Base\TagContentTrait addContent ( string|\Stringable $content ) | ||
| $content | string|\Stringable |
Tag content. |
final public function addContent(string|Stringable ...$content): static
{
$new = clone $this;
$new->content = array_merge($new->content, array_values($content));
return $new;
}
| public Yiisoft\Html\Tag\Base\TagContentTrait content ( string|\Stringable $content ) | ||
| $content | string|\Stringable |
Tag content. |
final public function content(string|Stringable ...$content): static
{
$new = clone $this;
$new->content = array_values($content);
return $new;
}
| public Yiisoft\Html\Tag\Base\TagContentTrait doubleEncode ( boolean $doubleEncode ) | ||
| $doubleEncode | boolean |
Whether already encoded HTML entities in tag content should be encoded.
Defaults to |
final public function doubleEncode(bool $doubleEncode): static
{
$new = clone $this;
$new->doubleEncode = $doubleEncode;
return $new;
}
| public Yiisoft\Html\Tag\Base\TagContentTrait encode ( boolean|null $encode ) | ||
| $encode | boolean|null |
Whether to encode tag content. Supported values:
|
final public function encode(?bool $encode): static
{
$new = clone $this;
$new->encode = $encode;
return $new;
}
| protected string generateContent ( ) | ||
| return | string |
Obtain tag content considering encoding options {@see \Yiisoft\Html\Tag\Base\encode()}. |
|---|---|---|
final protected function generateContent(): string
{
$content = '';
foreach ($this->content as $item) {
if ($this->encode || ($this->encode === null && !($item instanceof NoEncodeStringableInterface))) {
$item = Html::encode($item, $this->doubleEncode);
}
$content .= $item;
}
return $content;
}
Signup or Login in order to comment.