1. Go to this page and download the library: Download phly/phly-mustache 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/ */
phly / phly-mustache example snippets
use Phly\Mustache\Mustache;
echo $mustache->render('some-template', $view);
use Phly\Mustache\Resolver\DefaultResolver;
$resolver = new DefaultResolver();
$resolver->addTemplatePath($path1);
$resolver->addTemplatePath($path2);
$resolver = $mustache->getResolver()->attach($defaultResolver);
use Phly\Mustache\Resolver\DefaultResolver;
$resolver = $mustache->getResolver()->fetchByType(DefaultResolver::class);
$resolver->setSuffix('html'); // use '.html' as the suffix
use Phly\Mustache\Pragma\ImplicitIterator as ImplicitIteratorPragma;
$mustache->getPragmas()->add(new ImplicitIteratorPragma());
$mustache->render('template-with-pragma', $view);
class View
{
public $first_name = 'Matthew';
public $last_name = "Weier O'Phinney";
public function full_name()
{
return $this->first_name . ' ' . $this->last_name;
}
}