teg
v1.0.0
Published
Template Generator
Downloads
4
Maintainers
Readme
teg
teg is command-line utility to generate customized template/boilerplate files and folders.
Installation
Install it once globally:
npm install -g teg
Usage
Teg accepts two arguments. template
defines which template to use. file
defines the output filename.
teg <template> <file>
Templates
- A template is just a folder that contains files used to generate new files.
- Place templates in
~/.teg/templates
directory. - Template's files and folders named
_index(.*)
are automatically renamed to the file specified in the<file>
parameter.
Tags
- You can use tags inside templates.
- Currently only supported tag is
{{file}}
, which will be replaced by the name defined forfile
argument. - The case of the value of a tag can be changed by using a pipe:
{{file|paramCase}}
. Check out available methods.
Example of a template
A template can contain anything. Here's any example of a template to create React component, with a CSS file.
~/.teg/templates/react-const/_index.js
import React, { Component } from 'react'
const {{file}} = () => (
<div className="{{file|paramCase}}">
</div>
)
export default {{file}}
~/.teg/templates/react-const/_index.css
.{{file|paramCase}} {
display: flex;
}
To generate files from this template, run:
$ teg react-const NewComponent
This will generate two new files, NewComponent.js
and NewComponent.css
, in the current working directory, replacing {{file}}
tag with NewComponent
and {{file|paramCase}}
with new-component
.
TODO
- Custom
{{tags}}
inside templates - Configuration for tags' formatting