This repository was archived by the owner on Jan 31, 2020. It is now read-only.
File tree 2 files changed +21
-3
lines changed
src/Helper/Placeholder/Container
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -113,9 +113,14 @@ public function __toString()
113
113
*/
114
114
public function toString ($ indent = null )
115
115
{
116
- $ indent = ($ indent !== null )
117
- ? $ this ->getWhitespace ($ indent )
118
- : $ this ->getIndent ();
116
+ // If we don't have items - do not show prefix and postfix
117
+ if (! count ($ this )) {
118
+ return '' ;
119
+ }
120
+
121
+ $ indent = ($ indent === null )
122
+ ? $ this ->getIndent ()
123
+ : $ this ->getWhitespace ($ indent );
119
124
120
125
$ items = $ this ->getArrayCopy ();
121
126
$ return = $ indent
Original file line number Diff line number Diff line change @@ -432,4 +432,17 @@ public function testIndentationIsHonored()
432
432
$ this ->assertContains (" <ul> \n" , $ string , $ string );
433
433
$ this ->assertContains ("\n </ul> " , $ string , $ string );
434
434
}
435
+
436
+ public function testNoUsePrefixPostfixIfNoItems ()
437
+ {
438
+ $ this ->container ->setPrefix ("<h1> " )
439
+ ->setPostfix ("</h1> " );
440
+ $ string = $ this ->container ->toString ();
441
+ $ this ->assertEquals ('' , $ string );
442
+
443
+ $ this ->container ->set ('' );
444
+ $ string = $ this ->container ->toString ();
445
+ $ this ->assertEquals ('<h1></h1> ' , $ string );
446
+ }
447
+
435
448
}
You can’t perform that action at this time.
0 commit comments