Optional content argument for elements
Occasionally it is useful to create a Kolombido element with null
content. For example, if I want to construct a table I may wish to start with an empty tr
element and then conditionally append other elements in a specific order:
$tr = new Kolombido\HTML\Element('tr', null);
if ($cond) $tr->append_new('th', 'Conditional header');
$tr->append_new('th', 'Non-conditional header');
$table = new Kolombido\HTML\Element('table', new HTML\Element('thead', $tr));
Whilst I could avoid the null
content initialisation of $tr
using some sort of Ternary statement, I think this way is a bit neater and cleaner. It would be nice to be able to drop the explicit passing of the null
argument and instead be able to make the first line of this:
$tr = new Kolombido\HTML\Element('tr');
Edited by Sam White