- Modernized code a bit and added variables to blocks
This commit is contained in:
1 parent
722131d801
commit
778f84116b
12 files changed
+146
-52
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, '-')));
|
||||
|
||||
Reference in new issue
Block a user