28 lines
903 B
PHP
28 lines
903 B
PHP
<?php
|
|
$layoutScripts = $layoutScripts ?? [];
|
|
if (!is_array($layoutScripts)) {
|
|
$layoutScripts = [$layoutScripts];
|
|
}
|
|
?>
|
|
<?php require __DIR__ . '/footer.php'; ?>
|
|
<?php foreach ($layoutScripts as $script): ?>
|
|
<?php if (is_string($script)): ?>
|
|
<?= $script . PHP_EOL ?>
|
|
<?php elseif (is_array($script) && isset($script['src'])): ?>
|
|
<?php
|
|
$attrs = [];
|
|
if (!empty($script['defer'])) {
|
|
$attrs[] = 'defer';
|
|
}
|
|
if (!empty($script['module'])) {
|
|
$attrs[] = 'type="module"';
|
|
} elseif (!empty($script['type'])) {
|
|
$attrs[] = 'type="' . htmlspecialchars($script['type'], ENT_QUOTES) . '"';
|
|
}
|
|
?>
|
|
<script src="<?= htmlspecialchars($script['src'], ENT_QUOTES) ?>" <?= implode(' ', $attrs) ?>></script>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</body>
|
|
</html>
|