$view = view('my-view', ['name' => 'John']); $output = $view->getOutput(); echo $output;
$template = $this->get('view')->fetch('my-template.twig', ['name' => 'John']); $output = $this->get('view')->getOutput(); echo $output;In this example, we are rendering a Twig template called 'my-template.twig' and passing in a variable called 'name' with a value of 'John'. We then get the output of the view, store it in a variable called $output, and then echo it out to the screen. This example is using the SlimPHP framework and the Twig template engine.