tmpltn
v0.1.4
Published
In directory simple template generator
Downloads
4
Readme
tmpltn
Super lightweight in-directory project scaffolding
Installation
npm -g install tmpltn
Example Usage
- Define a template file
templates/model.tmpltn.js
/**
* TmpltnName: Model
* TmpltnDescription: Generic scaffolding for a Model
*/
// TmpltnOutput: lib/models/{{ train:name }}-model.js
class {{capitalize:camel:name}} {
}
// TmpltnOutput: test/models/{{ train:name }}-model-spec.js
var expect = require('expect.js');
describe('Models::{{capitalize:camel:name}}', function() {
});
- Run tmpltn
tmpltn gen Model name=Person
- Profit
tmpltn creates files:
lib/models/person-model.js
class Person {
}
test/models/person-model-spec.js
var expect = require('expect.js');
describe('Models::Person', function() {
});
Using Tmpltn
ls
Lists available templates
tmpltn ls
gen [opts] [name] [vars...]
Generates template of given name
using the variables provided.
Omit vars
to see available variables for a given file.
tmpltn gen Model
Possible variables: name
You may also overwrite the default output directory by specifying --output-path
.
tmpltn gen --output-path customDir/ Model name="Bob"
Template Files
The following tags are all valid:
TmpltnName
- the name of the template, used fortmpltn ls
TmpltnDescription
- the description for the template, used fortmpltn ls
TmpltnOutput
- the default output path for the file
Variable Transfomation
The following transformers may be used. (Feel free to submit a PR to add more!)
Transformation may also be chained. eg. {{ capitalize:camel:name }}
- camel -
My Name
->myName
- capitalize -
myName
->MyName
- snake -
My Name
->my_name
- train -
My Name
->my-name