Skip to content

Commit

Permalink
Update metadata and dependencies, fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
demurgos committed Apr 8, 2018
1 parent f0cdcaa commit b691423
Show file tree
Hide file tree
Showing 13 changed files with 12,363 additions and 1,214 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"parserOptions": {
"ecmaVersion": 2015
},
"extends": "google"
}
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Blaine Bublitz <[email protected]>
Charles Samborski <[email protected]>
Jamen Marzonie <[email protected]> (http://jamenmarz.com)
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
> Gulp plugin for compiling Pug templates
This Gulp plugin enables you to compile your Pug templates into HTML or JS, with support for template locals, custom Pug filters, AMD wrapping, and others. Here is a simple example using `gulp-pug`:

```javascript
var pug = require('gulp-pug');

Expand All @@ -14,7 +15,9 @@ gulp.task('views', function buildHTML() {
```

## API

### `pug([opts])`

- `opts` (`Object`): Any options from [Pug's API][api] in addition to `pug`'s own options.
- `opts.locals` (`Object`): Locals to compile the Pug with. You can also provide locals through the `data` field of the file object, e.g. with [`gulp-data`][gulp-data]. They will be merged with `opts.locals`.
- `opts.data` (`Object`): Same as `opts.locals`.
Expand All @@ -27,25 +30,28 @@ To change `opts.filename` use [`gulp-rename`][gulp-rename] before `gulp-pug`.
Returns a stream that compiles Vinyl files as Pug.

## Also See

- [`pug`][pug]
- [`gulp-data`][gulp-data]: Using locals in your Pug templates easier.
- [`gulp-rename`][gulp-rename]: Change `opts.filename` passed into Pug.
- [`gulp-wrap-amd`][gulp-wrap-amd]: Wrap your Pug in an AMD wrapper.

## Thanks

- Many thanks to [Blaine Bublitz][phated] for the original `gulp-jade` plugin.

## LICENSE

[MIT][license] &copy; Jamen Marzonie

[status]: https://travis-ci.org/pugjs/gulp-pug
[status-img]: https://travis-ci.org/pugjs/gulp-pug.png?branch=master
[deps]: https://david-dm.org/pugjs/gulp-pug.svg
[downloads]: https://img.shields.io/npm/dm/gulp-pug.svg
[pug]: http://github.com/pugjs/pug
[api]: https://pugjs.org/api/reference.html
[gulp-data]: https://npmjs.com/gulp-data
[gulp-rename]: https://npmjs.com/gulp-rename
[gulp-wrap-amd]: https://github.com/phated/gulp-wrap-amd
[phated]: https://github.com/phated
[license]: LICENSE
[status]: https://travis-ci.org/gulp-community/gulp-pug
[status-img]: https://travis-ci.org/gulp-community/gulp-pug.png?branch=master
[deps]: https://david-dm.org/gulp-community/gulp-pug.svg
[downloads]: https://img.shields.io/npm/dm/gulp-pug.svg
[pug]: http://github.com/gulp-community/pug
[api]: https://pugjs.org/api/reference.html
[gulp-data]: https://npmjs.com/gulp-data
[gulp-rename]: https://npmjs.com/gulp-rename
[gulp-wrap-amd]: https://github.com/phated/gulp-wrap-amd
[phated]: https://github.com/phated
[license]: LICENSE
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

var gulp = require('gulp');
var eslint = require('gulp-eslint');
const gulp = require('gulp');
const eslint = require('gulp-eslint');

gulp.task('eslint', function() {
gulp.src(['**/*.js', '!node_modules/**'])
return gulp.src(['*.js', 'test/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
Expand Down
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
'use strict';

var objectAssign = require('object-assign');
var through = require('through2');
var defaultPug = require('pug');
var ext = require('gulp-util').replaceExtension;
var PluginError = require('gulp-util').PluginError;
var log = require('gulp-util').log;
const objectAssign = require('object-assign');
const through = require('through2');
const defaultPug = require('pug');
const ext = require('gulp-util').replaceExtension;
const PluginError = require('gulp-util').PluginError;
const log = require('gulp-util').log;

module.exports = function gulpPug(options) {
var opts = objectAssign({}, options);
var pug = opts.pug || opts.jade || defaultPug;
const opts = objectAssign({}, options);
const pug = opts.pug || opts.jade || defaultPug;

opts.data = objectAssign(opts.data || {}, opts.locals || {});

return through.obj(function compilePug(file, enc, cb) {
var data = objectAssign({}, opts.data, file.data || {});
const data = objectAssign({}, opts.data, file.data || {});

opts.filename = file.path;
file.path = ext(file.path, opts.client ? '.js' : '.html');
Expand All @@ -25,8 +25,8 @@ module.exports = function gulpPug(options) {

if (file.isBuffer()) {
try {
var compiled;
var contents = String(file.contents);
let compiled;
const contents = String(file.contents);
if (opts.verbose === true) {
log('compiling file', file.path);
}
Expand Down
Loading

0 comments on commit b691423

Please sign in to comment.