gcds-card component introduces an undeclared dependency on the twig_tweak module

Created on 14 May 2025, 8 days ago

Problem/Motivation

An error is thrown when trying to display a gcds-card component in a twig template if the twig_tweak module is not installed so twig_tweak should be declared as a dependency.

Steps to reproduce

1) Install D11 and gcds theme
2) Try to show a gcds-theme in a twig template like this:

{{ include('gcds:gcds-card', {
    'card_title': 'I am the card title',
    'href': '#',
    'badge': 'rockin',
    'description': 'I am some stuff.',
  }, with_context = false)  }}

And you will get this error message:

The website encountered an unexpected error. Try again later.

Twig\Error\SyntaxError: Unknown "preg_replace" filter. in Twig\ExpressionParser->getFilter() (line 16 of themes/contrib/gcds/components/gcds-card/gcds-card.twig).
Twig\ExpressionParser->parseFilterExpressionRaw() (Line: 566)
Twig\ExpressionParser->parseFilterExpression() (Line: 514)
Twig\ExpressionParser->parsePostfixExpression() (Line: 364)
Twig\ExpressionParser->parsePrimaryExpression() (Line: 265)
Twig\ExpressionParser->getPrimary() (Line: 102)
Twig\ExpressionParser->parseExpression() (Line: 909)
Twig\ExpressionParser->parseNamedArguments() (Line: 870)
Twig\ExpressionParser->createArguments() (Line: 958)
Twig\ExpressionParser->parseSubscriptExpressionDot() (Line: 556)
Twig\ExpressionParser->parseSubscriptExpression() (Line: 512)
Twig\ExpressionParser->parsePostfixExpression() (Line: 364)
Twig\ExpressionParser->parsePrimaryExpression() (Line: 265)
Twig\ExpressionParser->getPrimary() (Line: 102)
Twig\ExpressionParser->parseExpression() (Line: 27)
Twig\TokenParser\DoTokenParser->parse() (Line: 202)
Twig\Parser->subparse() (Line: 42)
Twig\TokenParser\IfTokenParser->parse() (Line: 202)
Twig\Parser->subparse() (Line: 95)
Twig\Parser->parse() (Line: 559)
Twig\Environment->parse() (Line: 590)
Twig\Environment->compileSource() (Line: 131)
Drupal\Core\Template\TwigEnvironment->compileSource() (Line: 409)
Twig\Environment->loadTemplate() (Line: 371)
Twig\Environment->load() (Line: 496)
Twig\Environment->resolveTemplate() (Line: 1480)
Twig\Extension\CoreExtension::include() (Line: 72)
__TwigTemplate_afc207011f0147267257fd4d38957744->doDisplay() (Line: 388)
Twig\Template->yield() (Line: 344)
Twig\Template->display() (Line: 359)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 446)
Drupal\Core\Render\Renderer->doRender() (Line: 203)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 188)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Proposed resolution

Include twig_tweak module as a declared dependency in both gcds.info.yml and composer.json

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada justsomeguy.com

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024