1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-06 05:07:41 +02:00

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

This commit is contained in:
Awilum
2022-05-04 22:04:03 +03:00
parent 9d6ef33012
commit 067fc7a927
2 changed files with 8 additions and 0 deletions

View File

@@ -92,6 +92,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
if ($key == 'base64Encode') {
$content = strings($content)->{'base64Encode'}()->toString();
}
if ($key == 'between') {
$content = strings($content)->{'between'}(isset($values[0]) ? (string) $values[0] : '', isset($values[1]) ? (string) $values[1] : '')->toString();
}
}
return (string) $content;

View File

@@ -45,4 +45,8 @@ test('[strings] shortcode', function () {
// base64Encode
$this->assertEquals("dGVzdA==", parsers()->shortcodes()->parse('[strings base64Encode]test[/strings]'));
// between
$this->assertEquals("b", parsers()->shortcodes()->parse('[strings between=a|c]abc[/strings]'));
});