For a more detailed documentation visit the templify-docs.
- Concept
- Installation
- Docker
- Development
- Templates
- .templify
- Usage
- Placeholders
- templify-vault
- Bugs
- Release Notes
Working on a project often requires the creation of files with a similar structure. For example, a React component often consists of a .tsx
file, a .scss
file and a .test.tsx
file. templify allows you to create templates for such files and generate them from the command line.
It also allows you to specify the location of the generated files to keep your project structure clean.
You can see a real world example here.
Run the following command in your terminal to isntall the latest version of templify:
curl -s https://raw.githubusercontent.com/cophilot/templify/master/install | bash -s -- -y
Optionally you can specify a version with the -v
flag:
curl -s https://raw.githubusercontent.com/cophilot/templify/master/install | bash -s -- -y -v <version>
You can also define the installation path with the -p
flag:
curl -s https://raw.githubusercontent.com/cophilot/templify/master/install | bash -s -- -y -p /usr/local/bin
or download the binary from the latest release and place it in your $PATH
.
You may need to restart your terminal after installation for the changes to take effect.
After installation run
tpy version
to verify that the installation was successful.
- Download the
tpy.exe
binary from the latest release - Create a root folder for templify, e.g.
C:\Program Files\templify
- Inside the root folder create a folder called
bin
- Place the
tpy.exe
binary inside thebin
folder - Add the
bin
folder to your system's PATH variable
After installation run
tpy version
to verify that the installation was successful.
You can run an docker container with an installed templify version to try out the features. Just run the following commands:
git clone https://github.com/cophilot/templify.git
cd templify
docker build . --tag templify-image
docker run -it templify-image bash
You can either run the CLI tool directly on your machine or use the dev-container.
- Clone the repository
- Run
./scripts/setup
- Now you can run
cargo run <arguments> --dev
to run the CLI tool
TODO
The CI pipeline ensures the quality of the code. It runs the following checks:
- Format Check: Checks if the code is formatted correctly (Script: format-check)
- Comment Check: Checks if the code contains enough comments (Script: comment-check)
- Linter: Checks if the code is linted correctly (Script: lint)
- Test: Runs the test suite (Script: test)
You can find the pipeline configuration in the .github/workflows/check_rust_quality.yml file.
A template is a folder in the .templates
directory of your project. It contains all files and subfolders that should be generated when the template is used. You can use placeholders to replace parts of the template with the given values.
Each template must contain a .templify
file that specifies some metadata about the template.
The .templify
file contains metadata about the template. It is a key-value file with the following keys:
description
: A short description of the templatepath
: The path where the generated files should be placed based on the root of the project. This can also be a path with placeholders in it.
tpy [command]
Commands:
tpy help
Displays help for templify.
tpy version
Displays the current version of templify.
tpy init
Initializes templify in the current directory.
tpy new <template-name>
Creates a new template with the given name.
tpy load <url>
Load predefined templates from a GitHub repository into your project. The url should point to a folder inside a GitHub repository. Each folder inside there will be imported as a template in your .templates. See the templify-vault for more informations.
tpy list
Lists all available templates in the current project.
tpy generate <template-name> <given-name>
Generates a file from the given template.
$$name$$
: The name of the new file (This placeholder supports case conversion).$$year$$
: The current year.$$month$$
: The current month as a number.$$month-name$$
: The current month as a name.$$day$$
: The current day.$$git-name$$
: The name of the git user.
Case conversion is used to convert placeholders to different case styles. You can use them by adding a .
and the case style to a placeholder that supports case conversion.
Example: $$name.kebab$$
You can use the following case conversion:
$$<placeholder>.lower$$
: Lower case (e.g.mycomponent
)$$<placeholder>.upper$$
: Upper case (e.g.MYCOMPONENT
)$$<placeholder>.camel$$
: Camel case (e.g.myComponent
)$$<placeholder>.snake$$
: Snake case (e.g.my_component
)$$<placeholder>.kebab$$
: Kebab case (e.g.my-component
)$$<placeholder>.pascal$$
: Pascal case (e.g.MyComponent
)$$<placeholder>.macro$$
: Macro case (e.g.MY_COMPONENT
)$$<placeholder>.train$$
: Train case (e.g.My-Component
)
The templify-vault repository contains some default templates that you can import with the load
command.
Example:
You wanna start a new React project with typescript? Just run this command to import templates for default components for you React app:
tpy load https://github.com/cophilot/templify-vault/tree/main/React-ts
- no known bugs
- Refactoring
- Added variable placeholders
- Added
-reset
flag for thereload
command - Added
-force
flag for thegenerate
command - Added
-reload
flag for thegenerate
command - Added
-var
flag for thegenerate
command - Added
-default-var
flag for thegenerate
command - Short forms for case conversion
- Added divider selection support in the
.templify
file - Added global flag support
- Added
--quiet
global flag - Added
--dev
global flag - Added
--log-file
global flag - Initialize test suite
- CI pipeline for code quality checks
by Philipp B.