npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-job

v0.1.1

Published

Wrap compiled Gulp templates and bind them to an object

Readme

gulp-job NPM version Build status

Wrap files in self invoking functions that bind them to an object. Possibly compiled Jade templates.

Installation

npm install gulp-job

Use case

Gulp job will wrap a file in a self invoking function that in turn binds the 'file' to a namespace on an object. The following describes the specific use case that lead to the creation of gulp-job.

Lets say you have a Jade template, something like:

p Hello world

And you want to compile this, load it in as a client side script and then access it in a way such as:

window.templates.example([locals]);

Gulp-job can take a compiled template (my-example.js) such as:

function template(locals) {
  var buf = [];
  var jade_mixins = {};
  var jade_interp;

  buf.push("<p>Hello world</p>");
  return buf.join("");
}

and wrap it like so:

(function (window) {
  window.templates = window.templates || {};
  window.templates.myExample = function template(locals) {
    var buf = [];
    var jade_mixins = {};
    var jade_interp;

    buf.push("<p>Hello world</p>");
    return buf.join("");
}})(window);

Usage

var gulp = require('gulp'),
    jade = require('gulp-jade'),
    job = require('gulp-job');

gulp.task('job', function () {
  return gulp.src(['src/templates/*.jade'])
    .pipe(jade({ client: true }))
    .pipe(job())
    .pipe(gulp.dest('public/templates'));
});

This will compile your templates using gulp-jade and wrap them as shown above so that they can be included like normal js files.

Options

Gulp-job accepts an options object with the following attributes

parent (string)

default: 'window'

The object to bind to.

namespace (string)

default: 'templates'

The namespace to bind to

seperator (string)

default: '-'

The file name seperator. This will be used for converting file names to camel case object references.

i.e with the default settings the template file my-example.js would be accessible with:

window.templates.myExample();

It's a bit specific isn't it?

Yes it is, we had a very specific problem and we built a very specific solution to it. We also needed it to be part of our Gulp task flow.

Maybe someone else will have that very same specific problem one day; so here it is for all to use, fork, share, whatever.

Licence

MIT