UNPKG

gourmet-generator

Version:

Code generator using Javascript scripts and mustache templates

49 lines (28 loc) 1.32 kB
# Gourmet Create tasteful scripted templates for your repetiteve work. After that just do ./gourmet tasteful-script.js and enjoy! Use it to generate *entities*, *rest routes*, *sql* files, and anything else where a kickstart will be welcome. ## Simple Use js to explain what you want to do with a template. First example: ``` var tmpl = 'Hello {{name}}'; var value = { name: 'Daniel' }; var txt = tt.mustache(tmpl, value) tt.save('file-name.txt', txt) ``` ## Usage 1. Install gourmet-generator globally ```npm install -g gourmet-generator``` 2. Create a gourmet template script (like the one above) and save somewhere like ```/folder/templates/ex.js``` 3. Inside a cmd use: ```gourmet /folder/templates/ex.js param1 param2 param3``` ## API The tt is a global variable to execute frequently required stuff like: 1. Save a file: `tt.save(file, text);` where file is a path related to the folder where you currently are and text is the text that you want to save in utf8 2. Read: Sometimes its better to write the mustache files on its own file. `tt.read(file)` where file is a path related to the folder where you currently are 3. Render mustache: Will transform a mustache template and an object with values into a string `tt.mustache(template, values)`