Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.
/ Mustgen Public archive

File generator for mustache.js templates

License

Notifications You must be signed in to change notification settings

vladpazych/Mustgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

2. Add template hello.hbs at root of your project

Hello {{name}}.

Random words: {{#words}}{{.}} {{/words}}

{{#person}}
And this is block of {{name}} {{lastname}}.
{{/person}}

3. Add map.js at root of your project

var helloFile = {
    template: 'hello.hbs',
    output: 'hello.txt',
    data: {
        name: "totally useful tool",
        words: ["Lonely", "Sad", "Depressed"],
        person: {
            name: "Stephen",
            lastname: "King"
        }
    }
}

module.exports = {
    files: [helloFile],
    helpers: {},
    partials: {},
    // For safety reasons, output folder name 
    // should contain '_generated'. 
    // This folder will be constantly cleaned.
    output: '_generated'
};

4. Add server.js at root of your project

require('mustgen')('./', './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

Maintainer

About

File generator for mustache.js templates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published