sads
This commit is contained in:
@@ -1,27 +1,38 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../inc/helpers.php';
|
||||
|
||||
$layoutScripts = $layoutScripts ?? [];
|
||||
if (!is_array($layoutScripts)) {
|
||||
$layoutScripts = [$layoutScripts];
|
||||
}
|
||||
|
||||
foreach ($layoutScripts as $script) {
|
||||
if (is_string($script)) {
|
||||
$script = trim($script);
|
||||
if ($script === '') {
|
||||
continue;
|
||||
}
|
||||
tpl_add_script($script);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_array($script) || empty($script['src'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tpl_add_script(
|
||||
(string)$script['src'],
|
||||
$script['pos'] ?? 'footer',
|
||||
!empty($script['defer']),
|
||||
!empty($script['async']),
|
||||
(string)($script['type'] ?? ''),
|
||||
$script['version'] ?? null,
|
||||
!empty($script['module'])
|
||||
);
|
||||
}
|
||||
?>
|
||||
<?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; ?>
|
||||
<?php tpl_render_styles(null, 'footer'); ?>
|
||||
<?php tpl_render_scripts(null, 'footer'); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user