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