diff --git a/src/flextype/core/Parsers/Shortcodes/RegistryShortcode.php b/src/flextype/core/Parsers/Shortcodes/RegistryShortcode.php index 2a34c838..91cde62e 100644 --- a/src/flextype/core/Parsers/Shortcodes/RegistryShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/RegistryShortcode.php @@ -28,19 +28,11 @@ parsers()->shortcodes()->addHandler('registry', static function (ShortcodeInterf return ''; } - $varsDelimeter = ($s->getParameter('varsDelimeter') != null) ? parsers()->shortcodes()->parse($s->getParameter('varsDelimeter')) : ','; - if ($s->getParameter('get') != null) { - $value = $s->getParameter('get'); - - // Get vars - $vars = $value !== null ? strings($value)->contains($varsDelimeter) ? explode($varsDelimeter, $value) : [$value] : []; - - // Parse shortcodes for each var. - $vars = array_map(fn($v) => parsers()->shortcodes()->parse(is_string($v) ? $v : ''), $vars); - - $result = registry()->get($vars[0], $vars[1] ?? null); + $value = parsers()->shortcodes()->parse($s->getParameter('get')); + $default = ($s->getParameter('default') != null) ? parsers()->shortcodes()->parse($s->getParameter('default')) : null; + $result = registry()->get($value, $default); return is_array($result) ? serializers()->json()->encode($result) : $result; } diff --git a/tests/src/flextype/core/Parsers/Shortcodes/RegistryShortcodeTest.php b/tests/src/flextype/core/Parsers/Shortcodes/RegistryShortcodeTest.php index e63fb0bf..e7fe7900 100644 --- a/tests/src/flextype/core/Parsers/Shortcodes/RegistryShortcodeTest.php +++ b/tests/src/flextype/core/Parsers/Shortcodes/RegistryShortcodeTest.php @@ -5,5 +5,5 @@ declare(strict_types=1); test('[registry] shortcode', function () { expect(strings(parsers()->shortcodes()->parse("(registry get:'flextype.manifest')"))->isJson())->toBeTrue(); expect(parsers()->shortcodes()->parse("(registry get:'flextype.manifest.name')"))->toBe('Flextype'); - expect(parsers()->shortcodes()->parse("(registry get:'flextype.manifest.foo,Default')"))->toBe('Default'); + expect(parsers()->shortcodes()->parse("(registry get:'flextype.manifest.foo' default:'Default')"))->toBe('Default'); });