Skip to content
Snippets Groups Projects
Commit aef08e90 authored by Florent Torregrosa's avatar Florent Torregrosa
Browse files

Issue #3465432 by pdureau, Grimreaper: [2.0.0-beta1] empty variants in pattern() Twig function

parent 7ed8c4b9
No related branches found
No related tags found
1 merge request!165Issue #3465432 by pdureau, Grimreaper: [2.0.0-beta1] empty variants in pattern() Twig function
Pipeline #241608 passed with warnings
......@@ -56,8 +56,14 @@ class TwigExtension extends AbstractExtension {
$element = [
'#type' => 'pattern',
'#id' => $id,
'#variant' => $variant,
];
// Variant is a JSON-schema enum where empty string is not always allowed.
// Moreover, we don't allow empty variant.
if (!empty($variant)) {
$element['#variant'] = $variant;
}
// We use the compact format, so it will be resolved by
// RenderableConverter::resolveCompactFormat() before being converted to
// the SDC format.
......
......@@ -163,7 +163,6 @@ class ComponentPluginManager extends SdcPluginManager implements CategorizingPlu
}
return [
'title' => 'Variant',
'type' => 'string',
'$ref' => "ui-patterns://variant",
'enum' => $enums,
'meta:enum' => $meta_enums,
......
......@@ -14,10 +14,10 @@ use Drupal\ui_patterns\PropTypePluginBase;
#[PropType(
id: 'variant',
label: new TranslatableMarkup('Variant'),
description: new TranslatableMarkup('Prop Type for component variants.'),
description: new TranslatableMarkup('Prop type for component variants.'),
default_source: 'select',
schema: [],
priority: 10
schema: ['type' => ['string'], 'enum' => []],
priority: 1
)]
class VariantPropType extends PropTypePluginBase {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment