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

qgen

v3.1.18

Published

Generate files from templates

Readme

qgen logo

Build Status Greenkeeper badge Known Vulnerabilities

qgen generates files and folders from templates.

Some scenarios where qgen may come handy for you:

  • Generate a Jekyll blog post file from a template.
  • Generate files for a new React component from preset files.

using qgen

qgen is inspired by envato-tuts+’s Structurer.app.

Install

$ npm install -g qgen

Usage

Usage
	$ qgen <template name> [dest] [arguments] [options]

Options
	--directory=<dir>	Templates directory # Default: ./gqen-templates
	--config=<path>	Path to the JSON config file # Default: ./qgen.json
	--force	Overwrite the destination files
	--preview	Preview the results without making any changes on files

Examples
	$ qgen post # generates the post template in the current folder
	$ qgen post ./pages # generates the post template inside ./pages
	$ qgen post ./pages --page-title "Hello World" # generates the post template in inside ./pages with data field pageTitle="Hello World" to the template rendering engine

In your project folder (where packages.json is present), keep your templates files inside qgen-templates.

Templates

qgen uses Handlebars to render the template files.

The data arguments passed to CLI will be made available inside Handlebars templates as camel case context variables. Eg --page-title can be accessed in the template as pageTitle.

Example

Template with a single file

File ./qgen-templates/post.md

---
title: {{title}}
slug: {{slug}}
---
$ qgen post.md ./page --title "Hello World" --slug "hello-world"

Generated file ./page/post.md

---
title: Hello World
slug: hello-world
---

Template with multiple files

Keep all the files inside ./qgen-templates/my-component, where my-component will be the name of the template.

File ./qgen-templates/{{title}}.jsx

import React, { PropTypes } from 'react';

const {{title}} = () => (<div>{{title}}</div>);

export default {{title}};

File ./qgen-templates/{{title}}.css

.{{className}} {
	clear: both;
}
$ qgen my-component ./Dummy --title "Dummy" --class-name "dummy"

Generated file ./Dummy/Dummy.jsx

import React, { PropTypes } from 'react';

const Dummy = () => (<div>Dummy</div>);

export default Dummy;

Generated file ./Dummy/Dummy.css

.dummy {
	clear: both;
}

Templating filenames

You can use Handlebars templates to generate the filenames too.

Example: {{pageTitle}}.md file will be renamed to today.md, if you pass argument --page-title today while using qgen.

Note: Templates for filenames can only be used for files kept inside a folder. Read more on it under Template with multiple files.

‘qgen.json’, The configfile

You can use qgen.json to set options like, template directory, default destination, default argument values, etc.

{
	"directory": "./my-templates", // Default: "./qgen-templates"
	"dest": "./pages", // Destination for all templates. Default: "./"
	"helpers": "./handlebar-helpers.js", // Path to the Handlebars helpers. Default: undefined
	"templates": { // Default: {}
		"blog.md": { // These configuration will be passed while compiling template 'blog.md'
			"title": "A Fresh Title",
			"slug": "a-fresh-title",
			"dest": "./blog-pages" // Overrides the 'dest' for this template. Default: undefined
		}
	}
}

Using Handlebars Custom Helpers

You can load custom Handlebars helpers to qgen’s rendering engine. Pass the path to the file which exports the helper functions to the option helpers, either through the CLI param or, through config file. Here is a sample file which exports two custom helpers.

Tips & Tricks

Want to set a variable to today’s date?

Make use of the system date shell command.

$ qgen blog.md --filename=`date "+%Y-%m-%d"`

License

MIT © Saneef Ansari