Socket
Socket
Sign inDemoInstall

gulp-pug

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-pug - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

62

index.js
'use strict';
var extend = require('util')._extend;
var through = require('through2');
var pug = require('pug');
var extend = require('util-extend');
var gutil = require('gulp-util');
var replaceExtension = gutil.replaceExtension;
var PluginError = gutil.PluginError;
var defaultPug = require('pug');
var ext = require('gulp-util').replaceExtension;
var PluginError = require('gulp-util').PluginError;
module.exports = function gulpPug(opts) {
var baseOpts = extend({}, opts);
module.exports = function gulpPug(options) {
var opts = extend({}, options);
var pug = opts.pug || opts.jade || defaultPug;
return through.obj(function(file, enc, callback) {
var error = null;
return through.obj(function compilePug(file, enc, cb) {
opts.filename = file.path;
// Prepare new file.
var html = file.clone();
html.path = replaceExtension(html.path, '.html');
// Create options for pug.
var opts = extend({
filename: file.path
}, baseOpts);
// Locals
opts.data = opts.data || {};
var data = opts.data;
if (file.data) {
data = extend(data, file.data);
opts.data = file.data;
}
// Custom pug module
if (opts.pug) {
pug = opts.pug;
file.path = ext(file.path, opts.client ? '.js' : '.html');
if (file.isStream()) {
return cb(new PluginError('gulp-pug', 'Streaming not supported'));
}
// Replace contents
if (html.isBuffer()) {
if (file.isBuffer()) {
try {
var contents = pug.compile(file.contents.toString(), opts)(data);
html.contents = new Buffer(contents);
} catch (err) {
error = new PluginError('gulp-pug', err);
var compiled;
var contents = String(file.contents);
if (opts.client) {
compiled = pug.compileClient(contents, opts);
} else {
compiled = pug.compile(contents, opts)(opts.locals || opts.data);
}
file.contents = new Buffer(compiled);
} catch (e) {
return cb(new PluginError('gulp-pug', e));
}
} else {
error = new PluginError('gulp-pug', 'Unsupported file content');
}
// Continue
callback(error, error ? null : html);
cb(null, file);
});
};
{
"name": "gulp-pug",
"version": "2.0.0",
"description": "Gulp plugin for compiling Pug templates.",
"main": "index.js",
"scripts": {
"test": "eslint index.js test; ava -t | tap-spec"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jamen/gulp-pug.git"
},
"version": "3.0.0",
"description": "Compile Pug templates",
"keywords": [
"gulp",
"jade",
"pug",
"gulpplugin",
"pugjs"
"stream",
"compile"
],
"author": "Jamen Marzonie <jamenmarz@gmail.com> (http://jamenmarz.com/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/jamen/gulp-pug/issues"
"repository": "https://github.com/jamen/gulp-pug.git",
"dependencies": {
"gulp-util": "^3.0.2",
"pug": "^2.0.0-alpha6",
"through2": "^2.0.0"
},
"files": [
"index.js"
"index.js",
"LICENSE"
],
"homepage": "https://github.com/jamen/gulp-pug#readme",
"engines": {
"node": ">= 0.10"
},
"scripts": {
"test": "gulp eslint && tap ./test"
},
"license": "MIT",
"devDependencies": {
"ava": "^0.14.0",
"eslint": "^2.7.0",
"eslint-config-google": "^0.4.0",
"gulp": "^3.9.1",
"gulp-data": "^1.2.1",
"precommit": "^1.2.0",
"tap-spec": "^4.1.1"
},
"dependencies": {
"gulp-util": "^3.0.7",
"pug": "latest",
"through2": "^2.0.1",
"util-extend": "^1.0.3"
"eslint-config-google": "^0.5.0",
"eslint-config-xo": "^0.14.1",
"gulp": "^3.8.10",
"gulp-eslint": "^2.0.0",
"tap": "^1.3.1"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc