LogicException: Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead.

Created on 27 August 2018, about 6 years ago
Updated 7 October 2024, about 2 months ago

Hi

I'm using Token Embed Views to embed a Views Result as the Metatag Description using the Metatag โ†’ module.

It's all working fine most of the time but I am getting the above error intermittently on node pages - and nearly always on pages that are not nodes.

I've no idea how to create a patch but the error seems to point to line 39 of token_embed_views.tokens.inc where the render call is placed. If I update the code to $replacements[$original] = \Drupal::service('renderer')->renderPlain($view);, then all works fine. I know hacking code is a big no no but if someone else can create the patch, I would really appreciate the help.

Thanks a mil

F

๐Ÿ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ชIreland frankdesign

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau

    Have not seen this issueโ€ฆ how can this reproduced?

  • ๐Ÿ‡ฎ๐Ÿ‡ชIreland frankdesign

    We use the Paragraphs โ†’ module to create page content on our clients' websites. We then create a View of type Content that shows only the text from all the Paragraphs on a page using a Contextual Filter using Content ID. We then remove all tags from this text which merges all the text into one block of text. I then trim that text into 155 characters.

    Then using Token Embed Views โ†’ , we place that View into the Metatag Description field as the default value for each node (using the Metatag โ†’ module). So when a content creator creates a new node, if they don't manually enter a Metatag Description, at least there is a default value which is the first 155 characters from the page.

    We've been using this set-up on various versions of Drupal since D8. Currently the sites using this set up are now all on D10.3.6.

    Without the patch at #2, we were intermittently getting the error above the odd time on nodes and nearly always on non node pages (like Commerce Products pages or Views pages).

    Thanks for the heads up on the deprecated code. The deprecated code is still working on 10.3.6. However, I've just tested and the replacement code and that also fixes the error on 10.3.6.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau

    Sound really complicated to repro. Would be helpful if there is a step by step instruction that is less complicated. Also strange that it dies not happen all times.

    As I cannot repro with current info - Itherefore cannot rtbc an updated patch.

Production build 0.71.5 2024