grunt-new
Minimal generator. Adds files to existing projects with your choice of templates.
Last updated 7 years ago by hurrymaplelad .
BSD · Repository · Original npm · Tarball · package.json
$ cnpm install grunt-new 
SYNC missed versions from official npm registry.

grunt-new Build Status

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.loadNpmTasks('grunt-new');

grunt.initConfig({
  'new': {
    options: {
      engine: consolidate.handlebars
    }
    post: {
      template: 'templates/post.hbs',
      data: {
        title: 'Placeholder title',
        author: 'Your name here',
        dest: 'src/posts/my-new-post.md'
      }
    },
  },
})

Or something fancy like

pkg = require './package.json'
require('normalize-package-data')(pkg)

grunt.loadNpmTasks 'grunt-new'

grunt.initConfig
  new:
    options:
      engine: consolidate.handlebars
    post:
      template: 'templates/post.hbs',
      data: (done) ->
        # prompt the user for the title of the new post
        inquirer.prompt [{
          name: 'title'
          message: 'Title?'
        }], (err, {title}={}) ->
          # timestamp the new post filename
          date = grunt.template.today 'yyyy-mm-dd'
          slug = grunt.utils._.dasherize title.toLowerCase()
          done null,
            title: title
            author: pkg.author.name # grab the author name from package.json
            dest: "src/#{date}/#{slug}.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).

Current Tags

  • 0.0.0                                ...           latest (7 years ago)

1 Versions

  • 0.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |