code: public function renderContaoBackendTemplate(array $blocks = []): string
      {
          $request = $this->requestStack->getCurrentRequest();
  
          if (null === $request || !$this->scopeMatcher->isBackendRequest($request)) {
              return '';
          }
  
          /** @var BackendCustom $controller */
          $controller = $this->framework->createInstance(BackendCustom::class);
          $template = $controller->getTemplateObject();
  
          foreach ($blocks as $key => $content) {
              $template->{$key} = $content;
          }
  
          $response = $controller->run();
  
          return $response->getContent();
      }
docs: Renders a Contao back end template with the given blocks.