gulp-pug
Gulp plugin for compiling Pug templates. Enabling you to compile your Pug templates into HTML or JS, with support for template locals, custom Pug filters, AMD wrapping, and others.
Usage
const { src, dest } = require('gulp');
const pug = require('gulp-pug');
exports.views = () => {
return src('./src/*.pug')
.pipe(
pug({
// Your options in here.
})
)
.pipe(dest('./dist'));
};
API
pug([opts])
opts
(Object
): Any options from Pug's API in addition topug
's own options.opts.locals
(Object
): Locals to compile the Pug with. You can also provide locals through thedata
field of the file object, e.g. withgulp-data
. They will be merged withopts.locals
.opts.data
(Object
): Same asopts.locals
.opts.client
(Boolean
): Compile Pug to JavaScript code.opts.pug
: A custom instance of Pug forgulp-pug
to use.opts.verbose
: display name of file from stream that is being compiled.
To change opts.filename
use gulp-rename
before gulp-pug
.
Returns a stream that compiles Vinyl files as Pug.
Also See
pug
gulp-data
: Using locals in your Pug templates easier.gulp-rename
: Changeopts.filename
passed into Pug.gulp-wrap-amd
: Wrap your Pug in an AMD wrapper.gulp-frontmatter-wrangler
: Useful if you need YAML frontmatter at the top of your Pug file.
License
MIT