-
Notifications
You must be signed in to change notification settings - Fork 61
Don't show prefix and postfix if there is no placeholder items. #133
Conversation
@@ -118,6 +118,10 @@ public function toString($indent = null) | |||
: $this->getIndent(); | |||
|
|||
$items = $this->getArrayCopy(); | |||
// If we don't have items - do not show prefix and postfix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no item is present, then this check should the first step in this method. You can use $this->count()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide also an unit test for this new behaviour. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, check the last commit.
// If we don't have items - do not show prefix and postfix | ||
if (!count($items)) { | ||
if (!$this->count()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this check before $indent = ($indent !== null)
(line 116) and add a whitespace after !
.
return ''; | ||
} | ||
|
||
$itemsToString = implode($this->getSeparator(), $this->getArrayCopy()); | ||
// todo check empty $itemsToString after trim() to return '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If items with whitespace are added, then there is a reason for it and we should allow the rendering. Please undo this changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check please. I've made changes.
// If we don't have items - do not show prefix and postfix | ||
if (!$this->count()) { | ||
return ''; | ||
} | ||
|
||
$itemsToString = implode($this->getSeparator(), $this->getArrayCopy()); | ||
// todo check empty $itemsToString after trim() to return '' | ||
$indent = ($indent !== null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we should avoid the negative check:
$indent = $indent === null
? $this->getIndent()
: $this->getWhitespace($indent);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check it please.
@@ -113,8 +113,7 @@ public function __toString() | |||
*/ | |||
public function toString($indent = null) | |||
{ | |||
// If we don't have items - do not show prefix and postfix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment was good.
Don't show prefix and postfix if there is no placeholder items.
Thanks, @AndyDune; merged to develop for release with 2.10.0, as it is a slight change in behavior. |
For show h1 in layout with set in view file.