the FlightPHP documentation outlines how to switch template engine to Smarty, but how would I instead switch to Plates? I have added Plates via composer and its autoloaded.
From Custom Views section: https://flightphp.com/learn#views
<?
Flight::register('view', 'Smarty', array(), function($smarty){
$smarty->template_dir = './templates/';
$smarty->compile_dir = './templates_c/';
$smarty->config_dir = './config/';
$smarty->cache_dir = './cache/';
});
?>
How can I add the Plates engine from here instead? https://platesphp.com/engine/overview/
The process is exactly the same for Plates as it is for Smarty:
<?php
require '../lib/vendor/autoload.php';
// Register Plates as the template engine
Flight::register('view', 'League\Plates\Engine', ['../lib/templates']);
// Override the default render method
Flight::map('render', function($template, $data){
echo Flight::view()->render($template, $data);
});
Flight::route('/', function ()
{
// Render the Plates template using Flight's render method
Flight::render('hello', ['name' => 'World']);
});
Flight::start();