1. Go to this page and download the library: Download pug-php/pug 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/ */
pug-php / pug example snippets
= new Pug([
// here you can set options
]);
$pug->displayFile('my-pug-template.pug');
class UserKeyword
{
public function __invoke($arguments, $block, $keyWord)
{
$badges = array();
foreach ($block->nodes as $index => $tag) {
if ($tag->name === 'badge') {
$href = $tag->getAttribute('color');
$badges[] = $href['value'];
unset($block->nodes[$index]);
}
}
return [
'begin' => '<div class="' . $keyWord . '" data-name="' . $arguments . '" data-badges="[' . implode(',', $badges) . ']">',
'end' => '</div>',
];
}
}
$pug->addKeyword('user', new UserKeyword());
$pug->render('
user Bob
badge(color="blue")
badge(color="red")
em Registered yesterday
');
$myClosure = function ($string) {
return 'Hey you ' . $string . ', out there on your own, can you hear me?';
};
$pug->render('p=$myClosure("Pink")', array('myClosure' => $myClosure));
$pug = new Pug([
'cache' => 'pathto/writable/cachefolder/',
]);
$missingRequirements = array_keys(array_filter($pug->rements are missing.<br />';
foreach ($missingRequirements as $elist, please add it to your php.ini file.<br />';
break;
case 'cacheFolderExists':
echo 'The cache folder does not exists, please enter in a command line : <code>mkdir -p ' . $pug->getOption('cache') . '</code>.<br />';
break;
case 'cacheFolderIsWritable':
echo 'The cache folder is not writable, please enter in a command line : <code>chmod -R +w ' . $pug->getOption('cache') . '</code>.<br />';
break;
default:
echo $
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.