diff --git a/src/helpers/ComponentViewerHelper.php b/src/helpers/ComponentViewerHelper.php
index 02de173..b9bc0c6 100644
--- a/src/helpers/ComponentViewerHelper.php
+++ b/src/helpers/ComponentViewerHelper.php
@@ -130,8 +130,15 @@ public static function getComponent($componentId = '', $variant = null): array
$componentConfigPath = $componentMap[$componentId];
$twigString = file_get_contents($componentConfigPath);
$componentConfig = Json::decode(file_get_contents(self::getComponentConfigPath($componentConfigPath)));
+ $context = self::getComponentContext($componentId, $variant);
+
+ // Override the default context with the variant context
+ if ($context) {
+ $componentConfig['context'] = $context;
+ }
+
try {
- $rendered = Craft::$app->view->renderString($twigString, self::getComponentContext($componentId, $variant));
+ $rendered = Craft::$app->view->renderString($twigString, $context);
} catch (\Exception $e) {
$rendered = $e->getMessage();
}
@@ -139,7 +146,14 @@ public static function getComponent($componentId = '', $variant = null): array
try {
$readme = file_get_contents(self::getComponentReadmePath($componentId, $componentConfigPath));
} catch (\Exception) {
- $readme = 'Tags: {{ tags|join(",") }}
{% include "@{{ handle }}" with {{ jsonPrettyPrint(context) }} %}';
+ $readme = 'Tags: {{ tags|join(",") }}{% include \'@{{ handle }}\'';
+
+ // Only show `with { … }` in the include example if context exists
+ if ($context) {
+ $readme = $readme . ' with {{ context|json_encode(constant(\'JSON_PRETTY_PRINT\')) }}';
+ }
+
+ $readme = $readme . ' %}';
}
try {
$parser = new Markdown();
@@ -151,7 +165,7 @@ public static function getComponent($componentId = '', $variant = null): array
return [
'config' => $componentConfig,
- 'context' => self::getComponentContext($componentId, $variant),
+ 'context' => $context,
'readme' => $readme,
'twig' => $twigString,
'rendered' => $rendered,
diff --git a/src/templates/_components/atoms/btn/btn.twig b/src/templates/_components/atoms/btn/btn.twig
index 291979a..5dec9de 100644
--- a/src/templates/_components/atoms/btn/btn.twig
+++ b/src/templates/_components/atoms/btn/btn.twig
@@ -12,10 +12,10 @@
{% endif %}
{% if href is defined and href is not null %}
+? ' disabled' }} {{ attrs is defined ? attr(attrs) }}>
{% else %}
diff --git a/src/templates/_components/atoms/link/link.twig b/src/templates/_components/atoms/link/link.twig
index 73c3b6f..513de70 100644
--- a/src/templates/_components/atoms/link/link.twig
+++ b/src/templates/_components/atoms/link/link.twig
@@ -7,7 +7,7 @@
{{ secondary is defined ? '' : 'link-underline hover:link-underline-off' }}
hover:text-link-off
{{ group is defined and group == true ? 'group-hover:text-link-off group-hover:link-underline-off' : '' }}
- {{ customClasses is defined ? ' ' ~ customClasses }}" {{ attrs is defined ? attrs|arrayToAttributes|raw }}
+ {{ customClasses is defined ? ' ' ~ customClasses }}" {{ attrs is defined ? attr(attrs) }}
>
{% else %}
{% endif %}
{{ text }}
diff --git a/src/templates/_components/atoms/logo-splash/logo-splash.twig b/src/templates/_components/atoms/logo-splash/logo-splash.twig
index 041fcd2..4558054 100644
--- a/src/templates/_components/atoms/logo-splash/logo-splash.twig
+++ b/src/templates/_components/atoms/logo-splash/logo-splash.twig
@@ -33,7 +33,7 @@
"
style="{{ style }}"
aria-hidden="true"
- {{ attrs is defined ? attrs|arrayToAttributes|raw }}>
+ {{ attrs is defined ? attr(attrs) }}>
{% include '@foundation:splashes:'~type ignore missing with {
customClasses: "block w-full h-auto pointer-events-none "~(svgClassString|default('')),
diff --git a/src/templates/_components/atoms/topic/topic.twig b/src/templates/_components/atoms/topic/topic.twig
index d7e0f87..22e4466 100644
--- a/src/templates/_components/atoms/topic/topic.twig
+++ b/src/templates/_components/atoms/topic/topic.twig
@@ -10,7 +10,7 @@
px-8 pt-5 pb-3 lg:pb-4 uppercase inline-flex justify-center items-center
{% if href is defined and href != null %}hover:bg-tag hover:text-inverse focus:bg-tag focus:text-inverse{% endif %}
{{ customClasses is defined ? ' ' ~ customClasses }}"
- {{ attrs is defined ? attrs|arrayToAttributes|raw }}>
+ {{ attrs is defined ? attr(attrs) }}>
{{ text }}
{% if href is defined and href != null %}
diff --git a/src/templates/_components/atoms/video/video.twig b/src/templates/_components/atoms/video/video.twig
index 91427e2..2a2b04d 100644
--- a/src/templates/_components/atoms/video/video.twig
+++ b/src/templates/_components/atoms/video/video.twig
@@ -20,7 +20,7 @@
{{ script is defined ? script|raw }}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/src/templates/_components/behavior-blocks/filter-select/filter-select.twig b/src/templates/_components/behavior-blocks/filter-select/filter-select.twig
index a242a0c..ba2e40a 100644
--- a/src/templates/_components/behavior-blocks/filter-select/filter-select.twig
+++ b/src/templates/_components/behavior-blocks/filter-select/filter-select.twig
@@ -1,4 +1,4 @@
-