- Modernized code a bit and added variables to blocks

This commit is contained in:
mcndave committed 2026-07-01 12:57:01 -04:00
1 parent 722131d801
commit 778f84116b
12 files changed
+146 -52

No files matched your search

+2 -1
View File
@@ -23,7 +23,7 @@ class TitleExtension implements Extension, FunctionExtension {
"} ?>";
}
public function handleTitle(? string $set = null, ...$arguments) : ? string
public function handleTitle(null|\Stringable|string $set = null, ...$arguments) : ? string
{
if ( $set === null ) {
return $this->title;
@@ -31,6 +31,7 @@ class TitleExtension implements Extension, FunctionExtension {
else {
# Fixed a bug where template inheritance was rewriting title
if ( empty($this->title) ) {
$set = (string) $set;
$this->title = $arguments ? sprintf($set, ...$arguments) : $set;
}
}
+2 -2
View File
@@ -138,9 +138,9 @@ PATTERN;
}
# src: https://stackoverflow.com/a/14550919
public static function slug(string $text, string $separator = '-') : string
public static function slug(\Stringable|string $text, string $separator = '-') : string
{
$clean = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $text);
$clean = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', (string) $text);
$clean = preg_replace("/[^a-zA-Z0-9\/_| -]/", '', $clean);
return preg_replace("/[\/_| -]+/", $separator, strtolower(trim($clean, '-')));