1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-06 21:26:48 +02:00

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

This commit is contained in:
Awilum
2022-05-05 07:10:28 +03:00
parent 1447a92d83
commit e3e077727b
2 changed files with 7 additions and 0 deletions

View File

@@ -104,6 +104,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
if ($key == 'capitalize') {
$content = strings($content)->{'capitalize'}()->toString();
}
if ($key == 'chars') {
$content = serializers()->json()->encode(strings($content)->{'chars'}());
}
}
return (string) $content;

View File

@@ -55,4 +55,7 @@ test('[strings] shortcode', function () {
// capitalize
$this->assertEquals("That Country Was At The Same Stage Of Development As The United States In The 1940S", parsers()->shortcodes()->parse('[strings capitalize]that country was at the same stage of development as the United States in the 1940s[/strings]'));
// chars
$this->assertEquals('["c","a","r","_","f","ò","ô","_","b","à","ř","s","_","a","p","p","l","e"]', parsers()->shortcodes()->parse('[strings chars]car_fòô_bàřs_apple[/strings]'));
});