From ed8ca273aded31a5666525856da6e8a0e35d9580 Mon Sep 17 00:00:00 2001 From: Awilum Date: Wed, 4 May 2022 22:09:55 +0300 Subject: [PATCH] feat(shortcodes): `[strings]` shortcode - add `camel` modifier --- src/flextype/core/Parsers/Shortcodes/StringsShortcode.php | 4 ++++ .../flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php b/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php index 59b1feda..af7bc73c 100644 --- a/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php @@ -96,6 +96,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa if ($key == 'between') { $content = strings($content)->{'between'}(isset($values[0]) ? (string) $values[0] : '', isset($values[1]) ? (string) $values[1] : '')->toString(); } + + if ($key == 'camel') { + $content = strings($content)->{'camel'}()->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 1304c0cd..d287d280 100644 --- a/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php +++ b/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php @@ -49,4 +49,7 @@ test('[strings] shortcode', function () { // between $this->assertEquals("b", parsers()->shortcodes()->parse('[strings between=a|c]abc[/strings]')); + // camel + $this->assertEquals("fooBar", parsers()->shortcodes()->parse('[strings camel]foo_bar[/strings]')); + }); \ No newline at end of file