Controlador:
/** * @Route("/tabla/pintar", name="pintar") */ public function pintar() { $request = Request::createFromGlobals(); $ancho = $request->query->get('ancho'); $alto = $request->query->get('alto'); $tabla = "<table>"; for ($i = 0; $i < $alto; $i++) { $tabla .= "<tr>"; for ($j = 0; $j < $ancho; $j++) { $tabla .= "<td>" . ($j + $i * $ancho) . "</td>"; } $tabla .= "</tr>"; } $tabla .= "</table>"; return $this->render('tabla/tabla.html.twig', [ 'tabla' => $tabla, ]); }
vista:
{% extends 'base.html.twig' %} {% block title %}Tabla{% endblock %} {% block styles %} <style> footer{ background-color: red; } </style> {% endblock %} {% block body %} {# esto es un comentario #} <h1>Esta es la tabla que ha pedido</h1> {{tabla | raw}} <img src="{{ asset('img/gato.jpg') }}" alt=""/> {% endblock %}