grunt-new
Minimal generator. Add files to existing projects. Mix and match template engines. Anything supporting the Consolidate.js signaute will do.
npm install --save-dev grunt-new
Given a template file like templates/post.hbs
:
---title: {{title}}author: {{author}}---
You can do something real basic like
grunt; grunt
Or something fancy like
pkg = require './package.json'require'normalize-package-data'pkg gruntloadNpmTasks 'grunt-new' gruntinitConfig new: options: engine: consolidatehandlebars post: template: 'templates/post.hbs' : # prompt the user for the title of the new post inquirerprompt name: 'title' message: 'Title?' # timestamp the new post filename date = grunttemplatetoday 'yyyy-mm-dd' slug = gruntutils_dasherize titletoLowerCase done null title: title author: pkgauthorname # grab the author name from package.json dest: "src//.md"
Options
engine
Type: Function
Default value: _.template
A function that implements the Consolidate.js signature: function(path, data, callback)
and
calls its callback with (err, string)
.