Pug.php
Pug.php adds inline PHP scripting support to the Pug template compiler.
Pug has been recently re-named from Jade. If you're new to Pug, you should install the pug-php/pug package on composer.
The Pug Syntax Reference
Implementation details
The fork is a complete rewrite, all the code is ported from the original jade project.
All the features from the original are supported but undertested, including inheritance and mixins.
Install using composer
composer require pug-php/pug
composer install
Pug in your favorite framework
Phalcon: https://github.com/kylekatarnls/jade-phalcon
Symfony: https://github.com/kylekatarnls/jade-symfony
CodeIgniter: https://github.com/kylekatarnls/ci-jade
Pug options
Pug options should be passed to the Jade construction
$pug = new Pug(array(
'prettyprint' => true,
'extension' => '.pug',
'cache' => 'pathto/writable/cachefolder/'
);
Supports for local variables
$pug = new Pug();
$output = $pug->render('file', array(
'title' => 'Hello World'
));
Supports for custom filters
Filters must be callable: It can be a class that implements the __invoke() method, or an anonymous function.
$pug->filter('escaped', 'My\Callable\Class');
// or
$pug->filter('escaped', function($node, $compiler){
foreach ($node->block->nodes as $line) {
$output[] = $compiler->interpolate($line->value);
}
return htmlentities(implode("\n", $output));
});
Built-in filters
- :css
- :php
- :javascript
- :escaped
- :cdata
Install other filters with composer
http://pug-filters.selfbuild.fr/