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:
@@ -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;
|
||||
|
@@ -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]'));
|
||||
});
|
Reference in New Issue
Block a user