Open slaFFik opened 11 months ago
My dumb proof of concept (just to continue working on my package):
use cli\Streams;
use cli\Table;
class DynamicTable extends Table {
public function displayRow( $row ) {
$this->_renderer->setWidths( $this->_width, $fallback = true );
$border = $this->_renderer->border();
$out = [];
$row = $this->_renderer->row( $row );
$row = explode( PHP_EOL, $row );
$out = array_merge( $out, $row );
if ( isset( $border ) ) {
$out[] = $border;
}
foreach ( $out as $line ) {
Streams::line( $line );
}
}
}
Seems fine to me, as long as there aren't any backcompat breaks. Feel free to submit a PR if you'd like.
Awesome, @danielbachhuber. I will do that later today.
Feature Request
Describe your use case and the problem you are facing
I want to "register" an empty table, and then later in a loop using table reference (
$table
) add rows.Right now if I register a table, call the
display()
method to render it, and then later call theit will render the whole table again - with headers and previously added rows.
Describe the solution you'd like
I think separating
resetTable()
method into individual methods for header, rows, footer is needed.So I should be able to either do this:
or something like this:
Also, because header is a mandatory table data, displaying a new row should not render the top border but render the bottom row.