Get content from a view and return a JSON

Still, I give you some weird example :wink:

 /**
     * Display the info
     *
     * @return string
     */
    public function info()
    {
        ob_start();
        phpinfo();
        $phpinfo = ob_get_clean();
        $phpinfo = str_replace('img {float: right; border: 0;}', '', $phpinfo);
        $phpinfo = str_replace('a:link {color: #009; text-decoration: none; background-color: #fff;}', '', $phpinfo);

        return $this->view->render($this->response, $this->templateDir . '/info.twig', ['phpinfo' => $phpinfo]);
    }

My twig (the usefull part)

{% set title = 'Info' %}
{% extends common ~ 'layoutmain.twig' %}

{% block content %}
{{ phpinfo | raw }}
{% endblock %}