Use twig to show product boxes

I’m using the Silex framework combined with twig. And I’m creating a webshop system. Of course, products are on the website. So, I thought it would be easy to create a small template which show the individual products like this:
enter image description here

My twig created template is this one:

{{ name | capitalize }}
{{ type | capitalize }}

€ {{ price }}

But I'm using a class called Product to do things with a product (create, get, update and that sort of stuff). And there's a function to display a product. I'd like to use it like this:

public function showProduct($type, $name, $price){
    return $twig->render('product.twig', [
        'price' => $price,
        'type' => $type,
        'name' => $name,
    ]);
}

But of course this does not work since I haven't defined $twig and I'm rendering the complete page using another twig template. How can these problems be fixed?


Source: stackoverflow-php