1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-11 07:34:22 +02:00

feat(shortcodes): [strings] shortcode - add finish modifier

This commit is contained in:
Awilum
2022-05-05 09:19:01 +03:00
parent ac28422051
commit 0c3c36175a
2 changed files with 7 additions and 0 deletions

View File

@@ -141,6 +141,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
if ($key == 'endsWith') {
$content = strings($content)->{'endsWith'}(isset($vars[0]) ? (string) $vars[0] : '') ? "true" : "false";
}
if ($key == 'finish') {
$content = strings($content)->{'finish'}(isset($vars[0]) ? (string) $vars[0] : '')->toString();
}
}
return (string) $content;

View File

@@ -91,4 +91,7 @@ test('[strings] shortcode', function () {
// endsWith
$this->assertEquals("true", parsers()->shortcodes()->parse('[strings endsWith="/"]/movies/sg-1/season-5/episode-21/[/strings]'));
$this->assertEquals("false", parsers()->shortcodes()->parse('[strings endsWith="/"]/movies/sg-1/season-5/episode-21[/strings]'));
// finish
$this->assertEquals("/movies/sg-1/season-5/episode-21/", parsers()->shortcodes()->parse('[strings finish="/"]/movies/sg-1/season-5/episode-21[/strings]'));
});