grunt-templato

Overall project template management using Grunt

npm install grunt-templato
2 downloads in the last day
2 downloads in the last week
63 downloads in the last month

grunt-templato

Overall project template management using Grunt

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-templato --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-templato');

The "templato" task

Overview

In your project's Gruntfile, add a section named templato to the data object passed into grunt.initConfig().

grunt.initConfig({
  templato: {
    // exemple config with a JSON file 
    jsonConfig: {
      files: {
        'dest/path': 'src/path' // if 'src/path' is a folder, then all files below will be processed recursively
                                // and folder tree structure will be kept in the dest/path folder
      },
      values: grunt.file.readJSON('your/config.json') // you can use an external config.json file
    },
    // another example without the external JSON file
    defaultConfig: {
      files: {
        'tmp/fixtures/myProject': 'test/fixtures/myProject'
      },
      values: { // or use in-file configurations =)
        fooTitle: 'My title',
        PORT: 8042,
        list: {
          one: 1,
          two: 'secondOne'
        },
        dummyLog: 'some fake log'
      }
    }
  }
});

Options

TODO

Usage Examples

Once you have set up a src & dest path, if you run the task grunt templato it will generate in your dest folder the same files pointed out by src but processed by the template engine.

  files: {
    'dest/path': 'src/path' // if 'src/path' is a folder, then all files below will be processed recursively
                            // and folder tree structure will be kept in the dest/path folder
  },

Meaning that you have access to all the values you have given to templato in your files (pointed by your src folder) through the use of <%= VAR_NAME %>

<html>
<head>
    <title><%= fooTitle %></title>
</head>
<body>
    <ul>
        <li><%= list.one %></li>
        <li><%= list.two %></li>
    </ul>
</body>
</html>

or

public class Potato {
    private String PORT = "<%= PORT %>";
}

or

var dummy = require('dummy');
console.log('index.js > <%= dummyLog %>');

Custom Options

TODO

Contributing

Release History

10/01/2014 - v0.0.1

npm loves you