What is Mustgen?
Mustgen is a very simple file generator based on handlebars. It takes {{mustached}} template and javascript object as a map with values and file definitions, then generates string using handlebars, and writes it to a file.
Why it exists?
It was created as an alternative code generator for Entitas.
Quick start
0. Have Node.js installed
If you don't have node.js installed on your machine, install from Node.js website.
1. Go to your project path
$ cd pathToYourProject
1. Install Mustgen
$ npm install mustgen --save
hello.hbs
at root of your project
2. Add template Hello {{name}}. Random words: {{#words}}{{.}} {{/words}} {{#person}}And this is block of {{name}} {{lastname}}.{{/person}}
map.js
at root of your project
3. Add var helloFile = template: 'hello.hbs' output: 'hello.txt' data: name: "totally useful tool" words: "Lonely" "Sad" "Depressed" person: name: "Stephen" lastname: "King" moduleexports = files: helloFile helpers: {} partials: {} // For safety reasons, output folder name // should contain '_generated'. // This folder will be constantly cleaned. output: '_generated';
server.js
at root of your project
4. Add './' './map';
5. Run server
$ node server
6. Enjoy
Hello totally useful tool.
Random words: Lonely Sad Depressed
And this is block of Stephen King.
Code generation example
Check out EntitasMustgen, it's a boilerplate for Entitas API generation.
Handlebars docs
Handlebars website | Handlebars GitHub