(Formerly gulp-tale-jade)
Gulp plugin for Phug.
const gulp = require( 'gulp' );
const pug = require('gulp-phug');
function templates () {
return gulp.src('./src/*.pug')
.pipe(pug())
.pipe(gulp.dest('./dist'))
}
module.exports = {
default: templates
};Type: boolean, default: false
Compiles templates in Phug's debug mode. Debug output adds profiler calls and PUG_DEBUG markers to every line, which let Phug's own renderer map runtime errors back to .pug line numbers. It also makes the compiled PHP depend on the Phug runtime, so the server must have Phug installed (see Using with WordPress).
With debug off, the compiled PHP is self-contained and runs without Phug.
.pipe(pug({ debug: true }))When the option is not set, the plugin reads the GULP_PHUG_DEBUG environment variable (1, true, yes or on enable it). The option takes precedence over the variable.
GULP_PHUG_DEBUG=1 npx gulpPHP 7.1 or later must be available on your PATH (Phug 2 dropped support for older versions).
Uses composer which can be installed via Homebrew with brew install composer.
The compiled templates need Phug on the server only when compiled with debug: true. Without debug mode, WordPress can include them directly and these steps are unnecessary.
-
Install
composer(PHP's package manager) on your system; -
Create a folder
mu-pluginsinsidewp-content; -
Create a folder
phug-rendererinsidemu-plugins/; -
Install
phug; -
Create a file called
init.phpinsidemu-plugins, with the following content:<?php require_once( WPMU_PLUGIN_DIR . '/phug-renderer/index.php' );
-
cdintophug-rendererand run:composer require phug/phug -
Create the file
index.phpinphug-rendererwith the follwing content:<?php include_once __DIR__ . '/vendor/autoload.php';
-
Done. Now Wordpress will be able to render the PHP generated by the
phugcompiler.
The final structure should be:
mu-plugins/
init.php
phug-renderer/
vendor/
composer.json
composer.lock
index.php