Create a file based on a template and add it to component.json
.
npm install -g component-generate
$ component generate foo.js
It creates the file foo.js
based on the JavaScript default template. It also add the reference to the component.json
file.
{
...
"scripts": [
"foo.js"
]
}
-t
or --template
You can specify the template you want to use. The templates list is available here.
$ component generate index.js -t templateName
If you want to add a new template, you can add it in template/[extension]/[templateName].tpl
and make a PR. Templates are rendered using underscore.
In a future version, we will be able to use local templates. We need to find the simplest way to do it (see issue).
-p
or --params
Parameters that will be used by the template.
$ component generate index.js -t exports -p name:HomePage
Will render
'use strict';
module.exports = HomePage;
function HomePage() {
}
Released under the MIT license