What's this?
A library which allows to you very easily take input from a user, and use that data to build stuff. Like so:
var scaffoldit = ;; ;
The hello.mu.txt mustache template looks like:
hello {{name}}! {{#hasDog}}You have a dog.{{/has}} {{^hasDog}}You do NOT have a dog.{{/hasDog}}
And the result is:
scaffoldit(ops)
Options include:
params
- Default parameter values to pass onto the build callback.input
- Inputs that require a value from the user.[param_name]
- The parameter name for the given input.msg
- The message to display to the user.default
- The optional default value to use for the param. Can be a value, or callback.type
- Optional param for the type of input.
build
- The build function for the parameters given.complete
- Called once the build is complete.
Types of inputs
You can easily specify the type of input by adding (type-of-input)
before the message. Like to:
;
(prompt)
is the default option if you omit the type of input.
Default Parameters
;
scaffoldit.fromDir(params, src, dest)
Scans the target directory for mustache templates, and replaces any template variables with the parameters given. The destination is where the files are written to. Make sure to set the name of the template file to something like my-file.tpl.html
, or my-file.mu.html
.
Note that tpl
, and mu
are removed in the destination file.
Or you can do something like this:
;
scaffoldit.fromFile(params, templateSrc, callback)
loads the target mustache template file and fills it with the parameters given. Again, make sure to use this format my-file.mu.format
, or my-file.tpl.format
for consistency.
;