Use Pug template engine in WordPress. It uses pug-php under the hood.
To use this plugin you need to setup your WordPress installation via a Composer setup like Bedrock. Then you can install it via:
$ composer require sourceboat/wp-pug
The Plugin expects your templates to be under a views
folder in your active theme.
The plugin exposes the following helper functions:
render_template($name, $data = [])
- renders a template and prints the output.get_template_content($name, $data = [])
- renders a template and returns the output as string.
Arguments:
$name
- the template name relative to the template directory without file extension.$data
(optional) - array with local variables wich get passed to the template.
The plugin supports WP-CLI. The following commands are available:
$ wp pug cache warmup // caches all template files.
$ wp pug cache clear // clears all cached template files.