超薄3框架 - RenderView

I would like to render view and return it with JSON in my controler like the renderView in Symfony.

//use Slim\Container;
protected $ci;

    public function __construct(Container $ci)
    {
        $this->ci = $ci;
    }
public function AnalyseFacture(Request $request, Response $response,$args){
    $db    = $this->ci->dbLeak;
    $clients = self::RecuperationFacture($db);
    $data = $this->ci->view->render($response, 'envoiefacture/resultat-ajax.twig', ['liste' => $clients]);


    return $response->withJson(['data' => $data]);
}

I don't get what you try to achive, but if you want to return the rendered content within a json response then try this:

// ...

$this->ci->view->render($response, 'envoiefacture/resultat-ajax.twig', ['liste' => $clients]);

$data = (string)$response->getBody();

return $response->withJson(['data' => $data]);