diff --git a/src/TagInterface.php b/src/TagInterface.php index b52867d..3643634 100644 --- a/src/TagInterface.php +++ b/src/TagInterface.php @@ -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; diff --git a/src/TagTrait.php b/src/TagTrait.php index 430bf14..e651898 100644 --- a/src/TagTrait.php +++ b/src/TagTrait.php @@ -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;