diff --git a/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php b/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php index 8a36e683..37bc59b2 100644 --- a/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php @@ -145,6 +145,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa if ($key == 'finish') { $content = strings($content)->{'finish'}(isset($vars[0]) ? (string) $vars[0] : '')->toString(); } + + if ($key == 'firstSegment') { + $content = strings($content)->{'firstSegment'}(isset($vars[0]) ? (string) $vars[0] : ' ')->toString(); + } } return (string) $content; diff --git a/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php b/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php index 5007bbd3..7a869ed2 100644 --- a/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php +++ b/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php @@ -94,4 +94,8 @@ test('[strings] shortcode', function () { // finish $this->assertEquals("/movies/sg-1/season-5/episode-21/", parsers()->shortcodes()->parse('[strings finish="/"]/movies/sg-1/season-5/episode-21[/strings]')); + + // firstSegment + $this->assertEquals("SG-1", parsers()->shortcodes()->parse('[strings firstSegment]SG-1 returns from an off-world mission[/strings]')); + $this->assertEquals("SG", parsers()->shortcodes()->parse('[strings firstSegment="-"]SG-1 returns from an off-world mission[/strings]')); }); \ No newline at end of file