You are here

protected function HelpTopicsSyntaxTest::renderHelpTopic in Drupal 10

Renders a help topic in a special manner.

Parameters

string $content: Template text, without the front matter.

string $manner: The special processing choice for topic rendering.

Return value

string The rendered topic.

File

core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php, line 333

Class

HelpTopicsSyntaxTest
Verifies that all core Help topics can be rendered and comply with standards.

Namespace

Drupal\Tests\help_topics\Functional

Code

protected function renderHelpTopic(string $content, string $manner) {

  // Set up the special state variables for rendering.
  HelpTestTwigNodeVisitor::setStateValue('manner', $manner);
  HelpTestTwigNodeVisitor::setStateValue('max_chunk', -1);
  HelpTestTwigNodeVisitor::setStateValue('chunk_count', -1);

  // Add a random comment to the end, to thwart caching, and render. We need
  // the HelpTestTwigNodeVisitor class to hit it each time we render.
  $build = [
    '#type' => 'inline_template',
    '#template' => $content . "\n{# " . rand() . " #}",
  ];
  return (string) \Drupal::service('renderer')
    ->renderPlain($build);
}