Heinzelmannchen is a little helper for your daily work. It is used to create code from your templates and a datasource (i.e. a database). You have full control over the templates you'd like to use for your projects. This is the cli for the heinzelmannchen codegeneration tool.
- Nodejs installed (http://nodejs.org)
$ npm install heinzelmannchen-cli --global
How to use the CLI
Once installed you can use
heinzel in the terminal.
$ heinzel [commando] --help
I need some help
$ heinzel --help$ heinzel create --help
Setting up Heinzelmännchen
Heinzelmännchen needs a
.heinzelrc file to know what you want to do. You can easily create one,
by running the
init command. Or just run:
$ cd to/your/project$ touch .heinzelrc
.heinzelrc contains domains, which define a template and a datasource from a generator for creation.
If you want to use your own template for your
.heinzelrc file checkout (creating your own .heinzelrc.tpl).
A domain is defines a template and a generator which creates data for processing the template.
Domains are defined in the
.heinzelrc file and can be grouped for easier creation.
.heinzelrc file contains an object
domains which contains domainsdefinitions.
You can use templates from a repository or a folder on your system. If you want to use templates from a repository
you need to specify there location in the
You can reference the templates in the templaterepo by the name defined name. If you want to maintain the templates in a folder you can directly reference them in a domain.
Creating a template
To get going you need some templates. Templates can be writen in ERB-Style or you can set your own delimiters in the
Heinzelmännchen uses underscore to process the templates. So you can use the hole functionality from underscore, and additionaly the functionality from underscore.string.
Placeholders with a
= will be evaluated by underscore,
Hallo <%= name %> // if name = 'Anton' -> Hallo Anton
= it will be interpolated.
<% var age = 109 %> You are <%= age %> // -> You are 109
Finally your templates need some data. Heinzelmännchen uses generators, which create data from a source. You can create your own data if you don't find one in the npm reqistry (check out how to create a generator).
$ heinzel search -g keyword
To install a generator you can run
install in the terminal.
$ heinzel install -g ask
This will install heinzelmannchen-gen-ask in the nearest node_packages folder
and add it to the
To checkout what a generator does or what datastructur it returns run the following commands in your terminal.
$ heinzel explain ask
To setup your domains to use a generator just refer to the name. Some generators need a little of configuration. Take heinzelmannchen-gen-ask without configuration ask doesn't know what to do. The ask-generator takes your config and prompts it to set some values when you create a domain.
.heinzerc is all setup, you can create code for a specific domain.
heinzel create DOMAIN in the folder containing your
$ heinzel create express