Generators
Generators generate code.
Examples
This generator is static, meaning it does not accept any input. The output file README.md
will always be the same as the template template.hbs
:
outputs:
- generator:
filename: README.md
template: template.hbs
# Hello, world!
How are you today?
# Hello, world!
How are you today?
In order to accept input, add a Schema and Engine to your Generator:
name: My Application
description: My Application is an application.
outputs:
- generator:
engine: handlebars.js
filename: README.md
schema:
type: object
properties:
name:
required: true
type: string
description:
required: true
type: string
version:
required: true
type:
- number
- string
template: template.hbs
# {{{name}}} v{{{version}}}
{{{description}}}
module.exports = function(data, template) {
template = template.replace('{{{name}}}', data.name);
template = template.replace('{{{version}}}', data.version);
template = template.replace('{{{description}}}', data.description);
return template;
};
# My Application v1.0.0
My Application is an application.
The
handlebars.js
file in this example is meant to be a psuedo-Handlebars.js engine. Check out handlebars.template for a real working Engine for Handlebars.js.
Updated less than a minute ago