Problem/Motivation

As for UI patterns (Issue #3529153) since v1.0.2, we have error on example pages using theme: item_list

Error in the navigator :

Le site Web a rencontré une erreur inattendue.

Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template (""type" is an invalid render array key. Value should be an array but got a string.") in "customer:layout" at line 11. in Twig\Template->yield() (line 11 of themes/custom/customer/components/layout/layout.twig).

template_preprocess_item_list()
call_user_func_array() (Line: 261)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 77)
__TwigTemplate_ea68831567b6bbe1d179b4905979d5a4->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 141)
__TwigTemplate_03c9ed99ec99034085d3fa3357192c92___2130353984->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 44)
__TwigTemplate_03c9ed99ec99034085d3fa3357192c92->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 358)
Twig\Template->display() (Line: 373)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 234)
Drupal\Core\Template\TwigEnvironment->renderInline() (Line: 54)
Drupal\Core\Render\Element\InlineTemplate::preRenderInlineTemplate()
call_user_func_array() (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 875)
Drupal\Core\Render\Renderer->doCallback() (Line: 432)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
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()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
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: 741)

Steps to reproduce

  1. Use theme: item_list in an example
    Example :
    id: 'page-list-example'
    category: list
    enabled: true
    label: 'List example'
    render:
      - theme: item_list
        list_type: ul
        items:
          - type: html_tag
            tag: p
            value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ...'
          - type: html_tag
            tag: p
            value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ...'
          - type: html_tag
            tag: p
            value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ...'
        
  2. Open your example page in navigator

Proposed resolution

This bug also concerns UI Patterns v2.0.4

Our temporary solution is to prefix items content with #

For example :

- type: html_tag
  tag: p
  value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ...'

became :

- '#type': html_tag
  '#tag': p
  '#value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ...'

Is there a better solution ?

Thanks in advance for your help and feedback

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

malikah created an issue. See original summary.

grimreaper’s picture

Version: 1.0.2 » 1.x-dev

Hello,

The src/ExampleSyntaxConverter.php needs to be updated to support this case.

Please provide a MR with an example case in tests/src/Unit/ExampleSyntaxConverterTest.php and a fix in src/ExampleSyntaxConverter.php if possible.

anmolgoyal74 made their first commit to this issue’s fork.

anmolgoyal74’s picture

Status: Active » Needs review
Issue tags: +Vienna2025

@grimreaper As discussed, created the MR. Please have a look.

grimreaper’s picture

Status: Needs review » Needs work

Hi @anmolgoyal74,

Thanks for the MR!

I put 2 review comments.

Also please ensure code quality jobs are ok.

anmolgoyal74’s picture

Status: Needs work » Needs review

All the feedback has been addressed.

grimreaper’s picture

Assigned: Unassigned » grimreaper

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.