After the upgrade from Drupal Core 11.2.4 to 11.2.5, the Twig function "render" started to return an object instead of the string.
Try this code in any Twig template to reproduce:
{{ dump('Hello one'|t) }}
{{ dump('Hello two'|t|render) }}
{{ dump('Hello three'|t|render ~ '') }}
With Drupal Core 11.2.4 , the "Hello two" will be rendered as string, with 11.2.5 and later - as the TranslatableMarkup instead of the string:
Drupal\Core\StringTranslation\TranslatableMarkup {
#string: "Hello two"
#arguments: []
#translatedMarkup: null
#options: []
#stringTranslation: null
}
But if we force converting it to a string using a Twig construction, the conversion works well in the "Hello three" string.
This change was merged in the scope of the issue
📌
{% trans %} does not support render array and MarkupInterface valued placeholders
Needs work
:
https://git.drupalcode.org/project/drupal/-/merge_requests/2968/diffs#64...
if ($arg instanceof RenderableInterface) {
$arg = $arg->toRenderable();
}
+ elseif ($arg instanceof MarkupInterface) {
+ return $arg;
+ }
elseif (method_exists($arg, '__toString')) {
return (string) $arg;
}
If this change is intended, it is a pretty breaking change, so it's better to revert it if there are no real reasons to keep it as is.
And if we need to keep it, we need to create a change record, describing this change.
Active
11.2 🔥
render system
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.