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

dustfs

v0.0.7

Published

Simplified interface to {dust} and file templates for Node.js

Readme

{dust} with fs

Description

This is a simplified interface to use templates from filesystem with {dust} using Node.js.

Installation for Node.js

Simplest way to install is to use npm, just simply npm install dustfs. This will also install {dust} from npm.

License

MIT-style license, see INSTALL.txt.

Example 1 - Single template

File templates/hello.dust:

Hello {name}!

File hello.js:

var dustfs = require('dustfs');
dustfs.dirs('templates'); // Read templates from this directory
dustfs.render('hello.dust', {'name':'Captain Jack'}, function(err, out) {
	if(err) console.log('Error: '+err);
	else console.log(out);
});

Results for node hello.js:

Hello Captain Jack!

Example 2 - Multiple templates

File templates/layout.dust:

<body>
<div id="header">
{+header}
Header
{/header}
</div>
<div id="content">
{+content}
Default content.
{/content}
</div>
</body>

File templates/partial.dust:

{>"layout.dust"/}

{<header}
Hello, {name}!
{/header}

{<content}
This is our own content.
{/content}

File partial.js:

var dustfs = require('dustfs');
dustfs.debug(true);       // Enable optional debug using console.log
dustfs.dirs('templates'); // Read templates from that sub directory
dustfs.render('partial.dust', {'name':'Captain Jack'}, function(err, out) {
	if(err) console.log('Error: '+err);
	else console.log('Output:\n' + out);
});

Results for node partial.js:

[dustfs] [partial.dust] Waiting until directory loading is done before rendering...
[dustfs] [layout.dust] Template compiled from templates/layout.dust
[dustfs] [layout.dust] Template loaded: templates/layout.dust
[dustfs] [hello.dust] Template compiled from templates/hello.dust
[dustfs] [hello.dust] Template loaded: templates/hello.dust
[dustfs] [partial.dust] Template compiled from templates/partial.dust
[dustfs] [partial.dust] Template loaded: templates/partial.dust
[dustfs] [partial.dust] Loading done! Let's render!
[dustfs] [partial.dust] Rendering template...
Output:
<body><div id="header">Hello, Captain Jack!</div><div id="content">This is our own content.</div></body>

dustfs.dirs()

dustfs.dirs(directory) will compile and load all .dust files from the directory.

There is multiple ways to call dustfs.dirs.

Full syntax is: [returns EventEmiter] dustfs.dirs(dir[, dir2[, ...[, callback]]])

Note that using callbacks is not required since dustfs.render() will also wait for any ongoing loading.

Call to dustfs.dirs(dir[, dir2[, ...]]) returns an EventEmitter which can be used to catch errors or to catch when the loading has ended:

var loading = dustfs.dirs('templates', 'docroot');
loading.on('error', function(err) {
	console.log('Error: '+err);
});
loading.on('end', function() {
	console.log('Loading done!');
});

Call to dustfs.dirs(dir[, callback]) is a second way to handle events:

var loading = dustfs.dirs('templates', function(err) {
	if(err) console.log('Errors: ' + err);
	else console.log('Loading done!');
});

dustfs.render()

Call to dustfs.render(name, context, callback) will render the named template with provided context, and after that execute the callback with results:

dustfs.render('partial.dust', {'name':'Captain Jack'}, function(err, out) {
	if(err) console.log('Error: '+err);
	else console.log('Output:\n' + out);
});