The intention of Templatizer is to provide a handy and powerful mechanism to create custom projects from templates.
Gir repositories engines such as Github or Gitlab claim that they support repositories as templates. Actually, they only permit us to tag repositories as templates; but we will need to replace the "dynamic values" after copying/clonnig the templates. Sincerely, this is far to be a teamplate mechanism from my point of view.
Getting started
Templatizer takes advantage of existing template engines. So far, Templatizer supports Go Template but It's on the roadmap to provide other flavours such as Jinja.
Templatizer is meant to be executed as an executable file from your local machine. Thus, the communication with the repositories will be established on your own machine and the credentials won't be sent over the Internet.
Template
The template is the main piece used by Tempaltizer. A template is a Git repository hosted on any web repositories. The templates will contain values tp be dynamically replaced (variables). The varibales can be used in the content of the files but also in the name of folders and files.
To define the variables in the templates we will use the specified format by Go Template. Variables are defined as {{.variable}}. See the following example taken from a Go file.
The below screenshot shows an example of how we can use variabls in the name of the folders and the files.
Templatizer requires that the Tempalte reqpository host a file with the specification of the variables. This is not rocket science, we just need to enum the variables as shown in the below example::
version: v1
mode: goTemplate
variables:
- name: logger
default: github.com/sirupsen/logrus
- name: serverPort
default: 3000
- name: sitePath
description: Path to the static embedded foler
- name: organization
description: Name of the GH organization
The attributes version and mode could be omited since they are ignored in this version of Templatizer. Regarding the variables, only the attribute name. Anyway, the usage of the attributes description and default will help us to create handier and more useful templates.
By convection the name of this files is .templatizer.yml and It's in the root of your repository.