<commit_before># fgen

fgen is a file generator library to be used to generate project structures, file templates and/or snippets. Templates are based on the [mustache](http://mustache.github.com) template language.

In order to generate files, you need to provide a folder of templates and a context object to fgen, and fgen will generate the appropriate folder structures and files. fgen can be used as the core engine of any generator software.

## Example

Given you have a folder named `nodejs_templates`, with the following template files structure:

    .gitignore
    LICENSE
    README.md
    package.json
    lib/__name__.js
    test/

You can write a generator to generate all files or a single file as demonstrated below. You can also check `test/nodejs_project_templates/*` to have a feel of the template's content.

```js
var fgen = require("fgen");

// You provide a folder with mustache syntax template files.
fgen.createGenerator("nodejs_templates", function(err, generator) {
  if (err) {
    console.log(err);
    return;
  }

  // Underscore files like __name__.js will be substituted for the
  // corresponding values in the context object.
  generator.context = {
    name: "myProj",
    version: "0.0.0",
    desc: "My project desc.",
    keywords: [
      {keyword: "my"},
      {keyword: "project", last: true}
    ]
  };

  // Generate all files and folder structures.
  generator.generateAll("~/Desktop/myProj", function(err) {
    if (!err) { console.log("Successful generation."); }
  });

  // Single file generation.
  // generator.generate("LICENSE", "~/Desktop/myProj/LIC", function(err) {
  //   if (!err) { console.log("Successful generation."); }
  // });
});
```

## Installation

    $ npm install fgen

## Documentation

### fgen.createGenerator(templatesFolder, [readyListener])
<commit_msg>Enhance README.md<commit_after># fgen

fgen is a file generator library to be used to generate project structures, file templates and/or snippets. Templates are based on the [mustache](http://mustache.github.com) template language.

In order to generate files, you need to provide a folder of templates and a context object to fgen, and fgen will generate the appropriate folder structures and files. fgen can be used as the core engine of any generator software.

## Example

Given you have a folder named `nodejs_templates`, with the following template files structure:

    .gitignore
    LICENSE
    README.md
    package.json
    lib/__name__.js
    test/

You can write a generator to generate all files or a single file as demonstrated below. You can also check `test/nodejs_project_templates/*` to have a feel of the template's content.

```js
var fgen = require("fgen");

// You provide a folder with mustache syntax template files.
fgen.createGenerator("nodejs_templates", function(err, generator) {
  if (err) {
    console.log(err);
    return;
  }

  // Underscore files like __name__.js will be substituted for the
  // corresponding values in the context object.
  generator.context = {
    name: "myProj",
    version: "0.0.0",
    desc: "My project desc.",
    keywords: [
      {keyword: "my"},
      {keyword: "project", last: true}
    ]
  };

  // Generate all files and folder structures.
  generator.generateAll("~/Desktop/myProj", function(err) {
    if (!err) { console.log("Successful generation."); }
  });

  // Single file generation.
  // generator.generate("LICENSE", "~/Desktop/myProj/LIC", function(err) {
  //   if (!err) { console.log("Successful generation."); }
  // });
});
```

## Installation

```bash
$ npm install fgen
```

## Documentation

### fgen.createGenerator(templatesFolder, [readyListener])

{'fraction_non_alphanumeric': 0.11132280892759934, 'fraction_numerical': 0.001633097441480675, 'mean_word_length': 3.5652173913043477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1105878', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1033, 'n_words': 396}