{"id":15641044,"url":"https://github.com/saneef/qgen","last_synced_at":"2025-10-10T16:12:41.906Z","repository":{"id":51726448,"uuid":"53649223","full_name":"saneef/qgen","owner":"saneef","description":"qgen generates files and folders from templates","archived":false,"fork":false,"pushed_at":"2022-05-27T07:20:08.000Z","size":1443,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T09:09:44.753Z","etag":null,"topics":["cli","generator","handlebars","nodejs","scaffolding","template"],"latest_commit_sha":null,"homepage":"http://saneef.github.io/qgen/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saneef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"saneef","ko_fi":"saneef","patreon":"saneef"}},"created_at":"2016-03-11T07:47:39.000Z","updated_at":"2022-05-27T07:20:11.000Z","dependencies_parsed_at":"2022-08-03T08:00:42.949Z","dependency_job_id":null,"html_url":"https://github.com/saneef/qgen","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saneef%2Fqgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saneef%2Fqgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saneef%2Fqgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saneef%2Fqgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saneef","download_url":"https://codeload.github.com/saneef/qgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251674576,"owners_count":21625644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","generator","handlebars","nodejs","scaffolding","template"],"created_at":"2024-10-03T11:41:13.580Z","updated_at":"2025-10-10T16:12:36.868Z","avatar_url":"https://github.com/saneef.png","language":"JavaScript","funding_links":["https://github.com/sponsors/saneef","https://ko-fi.com/saneef","https://patreon.com/saneef"],"categories":[],"sub_categories":[],"readme":"![qgen logo](/media/qgen-logo.svg)\n\n[![Build Status](https://travis-ci.org/saneef/qgen.svg?branch=master)](https://travis-ci.org/saneef/qgen) [![Greenkeeper badge](https://badges.greenkeeper.io/saneef/qgen.svg)](https://greenkeeper.io/) [![Known Vulnerabilities](https://snyk.io/test/github/saneef/qgen/badge.svg?targetFile=package.json)](https://snyk.io/test/github/saneef/qgen?targetFile=package.json)\n\nqgen generates files and folders from templates.\n\nSome scenarios where qgen may come handy for you:\n\n- Generate a Jekyll blog post file from a template.\n- Generate files for a new React component from preset files.\n\n![using qgen](/media/qgen-example-usge.gif)\n\nqgen is inspired by envato-tuts+’s [Structurer.app](https://code.tutsplus.com/articles/free-mac-utility-app-structurer--net-17153).\n\n## Install\n\n\t$ npm install -g qgen\n\n## Usage\n\n```bash\nUsage\n\t$ qgen \u003ctemplate name\u003e [dest] [arguments] [options]\n\nOptions\n\t--directory=\u003cdir\u003e\tTemplates directory # Default: ./gqen-templates\n\t--config=\u003cpath\u003e\tPath to the JSON config file # Default: ./qgen.json\n\t--force\tOverwrite the destination files\n\t--preview\tPreview the results without making any changes on files\n\nExamples\n\t$ qgen post # generates the post template in the current folder\n\t$ qgen post ./pages # generates the post template inside ./pages\n\t$ 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\n```\n\nIn your project folder (where packages.json is present), keep your templates files inside `qgen-templates`.\n\n## Templates\n\nqgen uses [Handlebars](http://handlebarsjs.com) to render the template files.\n\nThe 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`.\n\n### Example\n\n#### Template with a single file\n\nFile `./qgen-templates/post.md`\n\n```markdown\n---\ntitle: {{title}}\nslug: {{slug}}\n---\n\n```\n\n```bash\n$ qgen post.md ./page --title \"Hello World\" --slug \"hello-world\"\n```\n\nGenerated file `./page/post.md`\n```markdown\n---\ntitle: Hello World\nslug: hello-world\n---\n\n```\n\n#### Template with multiple files\n\nKeep all the files inside `./qgen-templates/my-component`, where `my-component` will be the name of the template.\n\nFile `./qgen-templates/{{title}}.jsx`\n\n```jsx\nimport React, { PropTypes } from 'react';\n\nconst {{title}} = () =\u003e (\u003cdiv\u003e{{title}}\u003c/div\u003e);\n\nexport default {{title}};\n\n```\n\nFile `./qgen-templates/{{title}}.css`\n\n```css\n.{{className}} {\n\tclear: both;\n}\n\n```\n\n```bash\n$ qgen my-component ./Dummy --title \"Dummy\" --class-name \"dummy\"\n```\n\nGenerated file `./Dummy/Dummy.jsx`\n```jsx\nimport React, { PropTypes } from 'react';\n\nconst Dummy = () =\u003e (\u003cdiv\u003eDummy\u003c/div\u003e);\n\nexport default Dummy;\n\n```\n\nGenerated file `./Dummy/Dummy.css`\n```css\n.dummy {\n\tclear: both;\n}\n\n```\n\n### Templating filenames\n\nYou can use Handlebars templates to generate the filenames too.\n\n_Example:_ `{{pageTitle}}.md` file will be renamed to `today.md`, if you pass argument `--page-title today` while using qgen.\n\n**Note:** Templates for filenames can only be used for files kept inside a folder. Read more on it under [Template with multiple files](#template-with-multiple-files).\n\n## ‘qgen.json’, The configfile\n\nYou can use `qgen.json` to set options like, template directory, default destination, default argument values, etc.\n\n```javascript\n{\n\t\"directory\": \"./my-templates\", // Default: \"./qgen-templates\"\n\t\"dest\": \"./pages\", // Destination for all templates. Default: \"./\"\n\t\"helpers\": \"./handlebar-helpers.js\", // Path to the Handlebars helpers. Default: undefined\n\t\"templates\": { // Default: {}\n\t\t\"blog.md\": { // These configuration will be passed while compiling template 'blog.md'\n\t\t\t\"title\": \"A Fresh Title\",\n\t\t\t\"slug\": \"a-fresh-title\",\n\t\t\t\"dest\": \"./blog-pages\" // Overrides the 'dest' for this template. Default: undefined\n\t\t}\n\t}\n}\n```\n\n## Using Handlebars Custom Helpers\n\nYou 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](./test/fixtures/render-with-helper/src/qgen-helpers.js) which exports two custom helpers.\n\n## Tips \u0026 Tricks\n\n### Want to set a variable to today’s date?\n\nMake use of the system `date` shell command.\n\n```bash\n$ qgen blog.md --filename=`date \"+%Y-%m-%d\"`\n```\n\n## License\n\nMIT © [Saneef Ansari](https://saneef.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaneef%2Fqgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaneef%2Fqgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaneef%2Fqgen/lists"}