Add support for render arrays

Created on 18 July 2024, 6 months ago

Problem/Motivation

I'm creating about a dozen very similar shortcodes and I want to use a custom template for this.

When I set up a render array:

$cacheTags = [
      $shortcode,
    ];

    $render = [];
    $render[] = [
      '#theme' => 'statistics',
      '#classes' => $classes,
      '#statistic' => $statistic,
      '#reference' => $reference,
      '#cache' => [
        'max-age' => 64000,
        'tags' => $cacheTags,
      ],
    ];

    return $render;

I would expect this to render, instead I receive this error:

Warning: Array to string conversion in Drupal\shortcode\ShortcodeService->processTag() (line 449 of modules/contrib/shortcode/src/ShortcodeService.php).

and nothing renders.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

2.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States nicxvan

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

Comments & Activities

Production build 0.71.5 2024