Views and Layouts

Alter uses all the power of Twig to render templates.

You can render a view using the render() method of Callback object.

Route::get('/', function(){
  $this->render('index'); // Will render views/index.html

You can also organize your views into folders:

$this->render('cars.index'); // Will render views/cars/index.html

And pass data to the views:

$this->render('cars.index', ['car' => $car]); // Will render views/cars/index.html passing $car

Using Twig templates

You can read about how to use Tiwg templates in his documentation.


To use layouts with Alter you can use the extends method of Twig.

Leave a comment

Your email address will not be published. Required fields are marked *