Skip to content
tmslnzPublic

About

Pug (Jade) to PHP template compiler using Tale-Jade

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

33 Commits

Folders and files

Repository files navigation

npm

Gulp Phug

(Formerly gulp-tale-jade)

Gulp plugin for Phug.

Example usage

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
};

Options

debug

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 gulp

Requirements

PHP 7.1 or later must be available on your PATH (Phug 2 dropped support for older versions).

Development Setup

Uses composer which can be installed via Homebrew with brew install composer.

Using with WordPress

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.

  1. Install composer (PHP's package manager) on your system;

  2. Create a folder mu-plugins inside wp-content;

  3. Create a folder phug-renderer inside mu-plugins/;

  4. Install phug;

  5. Create a file called init.php inside mu-plugins, with the following content:

    <?php
    
    require_once( WPMU_PLUGIN_DIR . '/phug-renderer/index.php' );
  6. cd into phug-renderer and run: composer require phug/phug

  7. Create the file index.php in phug-renderer with the follwing content:

    <?php
    
    include_once __DIR__ . '/vendor/autoload.php';
  8. Done. Now Wordpress will be able to render the PHP generated by the phug compiler.

The final structure should be:

mu-plugins/
	init.php
	phug-renderer/
		vendor/
		composer.json
		composer.lock
		index.php

About

Pug (Jade) to PHP template compiler using Tale-Jade

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages