Skip to content

Commit ca05072

Browse files
author
Nana Axel
committed
Skip unused data table parts
1 parent c25620f commit ca05072

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/AirBubble/Tokens/DataTableToken.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ public function render(): ?\DOMNode
233233
$headPassed = false;
234234
$footPassed = false;
235235

236+
$skipHead = true;
237+
$skipFoot = true;
238+
236239
foreach ($data as $k => $v) {
237240
if (!$headPassed) {
238241
foreach ($this->_headers as $value) {
@@ -248,6 +251,10 @@ public function render(): ?\DOMNode
248251
$thead->getElementsByTagName("tr")->item(0),
249252
"<th>{$value}</th>"
250253
);
254+
255+
if ($skipHead && strlen($value) > 0) {
256+
$skipHead = false;
257+
}
251258
}
252259

253260
$headPassed = true;
@@ -284,15 +291,25 @@ public function render(): ?\DOMNode
284291
$tfoot->getElementsByTagName("tr")->item(0),
285292
"<th>{$value}</th>"
286293
);
294+
295+
if ($skipFoot && strlen($value) > 0) {
296+
$skipFoot = false;
297+
}
287298
}
288299

289300
$footPassed = true;
290301
}
291302
}
292303

293-
$domElement->appendChild($thead);
304+
if (!$skipHead) {
305+
$domElement->appendChild($thead);
306+
}
307+
294308
$domElement->appendChild($tbody);
295-
$domElement->appendChild($tfoot);
309+
310+
if (!$skipFoot) {
311+
$domElement->appendChild($tfoot);
312+
}
296313

297314
return $domElement;
298315
}

0 commit comments

Comments
 (0)