adding option to hide tags fully

This commit is contained in:
Joby Elliott 2019-07-09 11:13:08 -06:00
parent 1c5567f0af
commit 70f03e7d88
2 changed files with 15 additions and 0 deletions

View file

@ -11,6 +11,7 @@ interface TagInterface
public function hasClass(string $name) : bool;
public function removeClass(string $name);
public function classes() : array;
public function hidden($hidden=null);
public function string() : string;

View file

@ -10,6 +10,15 @@ trait TagTrait
protected $classes = [];
protected $attributes = [];
protected $hidden = false;
public function hidden($hidden=null)
{
if ($hidden !== null) {
$this->hidden = $hidden;
}
return $this->hidden;
}
protected function htmlContent()
{
@ -79,6 +88,11 @@ trait TagTrait
public function string() : string
{
//output empty string if hidden
if ($this->hidden()) {
return '';
}
//build output
$out = '';
//build opening tag
$out .= '<'.$this->tag;