Skip to main content

How to render a node

Posted on May 28, 2020


You can render a $node as follows:

$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$view_mode = 'default';
$course_view = $view_builder->view($node, $view_mode); // render array

Note: use dependency injection whenever possible.