Problem/Motivation
The following error occurs in Drupal 10.4.3 with Twig v3.19.0:
The website encountered an unexpected error. Try again later.
Twig\Error\SyntaxError: Unexpected token "name" of value "if" ("end of statement block" expected). in Twig\TokenStream->expect() (line 5 of modules/contrib/forum_access/templates/forum-access-table.html.twig).
Twig\TokenParser\ForTokenParser->parse(Object) (Line: 202)
Twig\Parser->subparse(Array) (Line: 42)
Twig\TokenParser\IfTokenParser->parse(Object) (Line: 202)
Twig\Parser->subparse(NULL, ) (Line: 95)
Twig\Parser->parse(Object) (Line: 559)
Twig\Environment->parse(Object) (Line: 590)
Twig\Environment->compileSource(Object) (Line: 131)
Drupal\Core\Template\TwigEnvironment->compileSource(Object) (Line: 409)
Twig\Environment->loadTemplate('__TwigTemplate_82e7ac16ef626a053af3fefb7f6232d9', 'modules/contrib/forum_access/templates/forum-access-table.html.twig') (Line: 371)
Twig\Environment->load('modules/contrib/forum_access/templates/forum-access-table.html.twig') (Line: 33)
twig_render_template('modules/contrib/forum_access/templates/forum-access-table.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('forum_access_table', Array) (Line: 491)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
Install the module in a Drupal 10+ installation using twig 3+ and try to edit a forum or a container.
Proposed resolution
Modify the forum-access-table.html.twig template to make it work with twig 3 by separating if clauses from for loops as for if is deprecated since Twig 2.10 (see https://twig.symfony.com/doc/2.x/deprecated.html#tags).
Remaining tasks
User interface changes
N/A
API changes
N/A
Data model changes
N/A