Module: dgen

Universal generator module to create directories files and template based contents

Methods

(static) convertMarkdown(doc) → {Object}

Convert each markdown-format fields of the object to HTML

Parameters:
Name Type Description
doc Object

The document

Returns:
  • A copy of the original document with processed markdown field values
Type
Object

(static) copyDir(opts)

Copy directories

Parameters:
Name Type Description
opts Object

The options of the copy operation. An object which has the following properties:

 {
     sourceBaseDir: {String},        // The path to the base directory to copy from
     targetBaseDir: {String},        // The path to the base directory to copy into
     dirName: {String},              // The directory to copy
     forceDelete: {Boolean},         // Whether to overwrite existing directory or not
     excludeHiddenUnix: {Boolean},   // Whether to copy hidden Unix files or not (preceding .)
     preserveFiles: {Boolean},       // If we're overwriting something and the file already exists, keep the existing
     inflateSymlinks: {Boolean}      // Whether to follow symlinks or not when copying files
     filter: {RegExp},               // A filter to match files against; if matches, do nothing (exclude).
     whitelist: {Boolean},           // if true every file or directory which doesn't match filter will be ignored
 }

(static) copyFile(fileName, sourceBaseDir, targetBaseDir)

Copy one file

Parameters:
Name Type Description
fileName String

The name of the file to copy

sourceBaseDir String

The source directory

targetBaseDir String

The target directory

(static) processTemplate(context, opts)

Process a Handlebars template and extrapolates with the given context data, and write into a file.

Parameters:
Name Type Description
context Object

The context data to fill into the template

opts Object

The template options:

 {
     sourceBaseDir: {String}     // The path to the directory of the templates and partials
     template: {String}          // The name of the main template file
     targetBaseDir: {String}     // The path to the directory of the target file
     target: {String}            // The name of the target file
 }

(inner) loadPartials(basePath) → {Object}

Load template partial files

The function loads every file in the given folder, as a text file, then
then hangs them to an object, as properties.
The property names will be the filenames, of the original partial files, without the full path.

Parameters:
Name Type Description
basePath String

The path to the directory which contains the partials

Returns:
  • An object, which contains the partials.
Type
Object