enabling Twig as Template Engine withing own plugin [closed]

I would use output buffering to capture the content, then pass that in to the template.

ob_start();
settings_fields('settings');
$settings_fields = ob_get_clean();
echo $this->twig->render($file, ['val1' =>  $settings_fields]);

I think that should work.

error code: 523