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
-
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 ...'
-
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
Comments
Comment #2
grimreaperHello,
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.
Comment #5
anmolgoyal74 commented@grimreaper As discussed, created the MR. Please have a look.
Comment #6
grimreaperHi @anmolgoyal74,
Thanks for the MR!
I put 2 review comments.
Also please ensure code quality jobs are ok.
Comment #7
anmolgoyal74 commentedAll the feedback has been addressed.
Comment #8
grimreaperComment #10
grimreaper