Twig, Tests, AES,
This commit is contained in:
@@ -11,21 +11,35 @@ class Script extends StaticView {
|
||||
const INSTALL = "/js/install.js";
|
||||
const BOOTSTRAP = "/js/bootstrap.bundle.min.js";
|
||||
const ACCOUNT = "/js/account.js";
|
||||
const SECLAB = "/js/seclab.min.js";
|
||||
const FONTAWESOME = "/js/fontawesome-all.min.js";
|
||||
|
||||
private string $type;
|
||||
private string $content;
|
||||
private string $src;
|
||||
private ?string $nonce;
|
||||
|
||||
function __construct($type, $src, $content = "") {
|
||||
$this->src = $src;
|
||||
$this->type = $type;
|
||||
$this->content = $content;
|
||||
$this->nonce = null;
|
||||
}
|
||||
|
||||
function getCode(): string {
|
||||
$src = (empty($this->src) ? "" : " src=\"$this->src\"");
|
||||
return "<script type=\"$this->type\"$src>$this->content</script>";
|
||||
$attributes = ["type" => $this->type];
|
||||
if (!empty($this->src)) {
|
||||
$attributes["src"] = $this->src;
|
||||
}
|
||||
|
||||
if (!empty($this->nonce)) {
|
||||
$attributes["nonce"] = $this->nonce;
|
||||
}
|
||||
|
||||
$attributes = html_attributes($attributes);
|
||||
return "<script $attributes>$this->content</script>";
|
||||
}
|
||||
|
||||
public function setNonce(string $nonce) {
|
||||
$this->nonce = $nonce;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user