make scriptTag parameter a string for flexibility and clarity

This commit is contained in:
El RIDO 2024-07-09 21:38:41 +02:00
parent 7294ea7847
commit d27e7e8ee3
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
4 changed files with 30 additions and 30 deletions

View file

@ -63,15 +63,15 @@ class View
*
* @access private
* @param string $file
* @param bool $async should it execute ASAP or only after HTML got parsed
* @param string $attributes additional attributes to add into the script tag
*/
private function _scriptTag($file, $async = true)
private function _scriptTag($file, $attributes = '')
{
$sri = array_key_exists($file, $this->_variables['SRI']) ?
' integrity="' . $this->_variables['SRI'][$file] . '"' : '';
$suffix = preg_match('#\d.js$#', $file) == 0 ?
'?' . rawurlencode($this->_variables['VERSION']) : '';
echo '<script ', $async ? 'async' : 'defer',
echo '<script ', $attributes,
' type="text/javascript" data-cfasync="false" src="', $file,
$suffix, '"', $sri, ' crossorigin="anonymous"></script>', PHP_EOL;
}