PHP code example of akawalko / latte-template-renderer
1. Go to this page and download the library: Download akawalko/latte-template-renderer library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
akawalko / latte-template-renderer example snippets
// app/dependencies.php
return function (ContainerBuilder $containerBuilder) {
LatteRenderer::class => function (ContainerInterface $c) {
$latte = new \Latte\Engine();
$latte->setLoader(new FileLoader($c->get('templates.directory.host')));
$latte->setTempDirectory($c->get('templates.directory.temp_directory'));
$latte->setAutoRefresh($c->get('templates.directory.auto_refresh'));
// If you have any additional filters or extensions, register them now.
//$latte->addExtension(new SomekindExtension());
//$latte->addFilter('some_filter', fn(string $s) => ...);
return new LatteTemplateRenderer($latte);
},
// A convenient alias
'template' => get(TemplateRenderer::class),
};
$obj = new \stdClass();
$obj->firstname = 'John';
$obj->lastname = 'Connor';
$obj->age = '34';
$latteRenderer->setVars($obj);