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

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

This commit is contained in:
Awilum
2022-05-04 21:56:41 +03:00
parent 3a41115328
commit 07117c13a6
2 changed files with 8 additions and 0 deletions

View File

@@ -84,6 +84,11 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
if ($key == 'at') {
$content = strings($content)->{'at'}((int) $values)->toString();
}
if ($key == 'base64Decode') {
$content = strings($content)->{'base64Decode'}()->toString();
}
}
return (string) $content;

View File

@@ -39,4 +39,7 @@ test('[strings] shortcode', function () {
$this->assertEquals("a", parsers()->shortcodes()->parse('[strings at=0]abc[/strings]'));
$this->assertEquals("b", parsers()->shortcodes()->parse('[strings at=1]abc[/strings]'));
$this->assertEquals("c", parsers()->shortcodes()->parse('[strings at=2]abc[/strings]'));
// base64Decode
$this->assertEquals("test", parsers()->shortcodes()->parse('[strings base64Decode]dGVzdA==[/strings]'));
});