I am having a problem converting an old project that uses savant2 template engine to plates template engine, I have gone through the platesphp documentation, and it is still confusing. The project in savant2 template is structured this way(example), first file
$savant = new Savant2();
$savant->addPath('template', [LINK TO TEMPLATE OR THEME]);
Then in other file, where the needed variables are declared
global $savant;
$my_name = "Victor";
$savant->assign('name', $my_name);
$savant->display('include/header.tmpl.php');
Then, in the header.tmpl.php file
<?php echo $this->name; ?>
Now, I want to use plates template engine instead to replace savant2, this is how my code is now structure, first file
$plates = new League\Plates\Engine();
$plates->addFolder('template', [LINK TO TEMPLATE OR THEME]);
In the other file,
global $plates;
$my_name = "Victor";
$plates->addData('name', $my_name);
$plates->render('include/header.tmpl.php');
Then, In the header.tmpl.php file
<?=$this->e($name)?>
Though it is not working as expected, my confusion lies in the use of render,addData, and addFolder to produce the same results as savant2
I finally solved it
Replace the above, and add this instead
Then for the below savant2 implementation
Replace it with this plates implementation
Then for the template files (Savant2)
Replace with the below (For Plates)
And there you have your previously savant2 app, now running on plates template engine