1. Go to this page and download the library: Download phalette/platte 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/ */
phalette / platte example snippets
use Phalette\Platte\Latte\LatteFactory;
use Phalette\Platte\LatteTemplateAdapter;
$di->set('view', function () {
$view = new View();
$view->registerEngines([
".latte" => function ($view, $di) {
$factory = new LatteFactory();
$factory->setTempDir(__DIR__ . '/cache');
return new LatteTemplateAdapter($view, $di, $factory);
},
]);
return $view;
});
use Latte\Compiler;
use Latte\Macros\MacroSet;
use Phalette\Platte\Latte\MacroInstaller;
final class MyUltraMacros extends MacroSet implements MacroInstaller
{
public static function install(Compiler $compiler)
{
$me = new static($compiler);
$me->addMacro(...);
}
}
$factory = new LatteFactory();
$factory->addMacro(new MyUltraMacros);
final class MyUltraFilters
{
public static function hi($name)
{
return "Hi $name";
}
}
$factory = new LatteFactory();
$factory->addFilter('sayhi', ['MyUltraFilters', 'hi']);
latte
<ul>
{foreach $users as $user}
<li>{$user->name}</li>
{/foreach}
</ul>
latte
<ul n:foreach="$users as $user">
<li>{$user->name}</li>
</ul>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.