mirror of
https://github.com/flextype/flextype.git
synced 2025-08-08 22:26:46 +02:00
feat(shortcodes): [strings]
shortcode - add endsWith
modifier
This commit is contained in:
@@ -137,6 +137,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
|
||||
if ($key == 'countSubString') {
|
||||
$content = (string) strings($content)->{'countSubString'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : true);
|
||||
}
|
||||
|
||||
if ($key == 'endsWith') {
|
||||
$content = strings($content)->{'endsWith'}(isset($vars[0]) ? (string) $vars[0] : '') ? "true" : "false";
|
||||
}
|
||||
}
|
||||
|
||||
return (string) $content;
|
||||
|
@@ -88,4 +88,7 @@ test('[strings] shortcode', function () {
|
||||
// crc32
|
||||
$this->assertEquals(3632233996, parsers()->shortcodes()->parse('[strings crc32]test[/strings]'));
|
||||
|
||||
// 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]'));
|
||||
});
|
Reference in New Issue
Block a user