A lot of projects start from a set of identical skeletons. For example, a project for a Python library should have the basic structure including a setup.py and a few CI jobs. A react webpack project should have a node package configuration and the webpack configuration. Only a few properties have to be adjusted for the initial commit of the project, such as the name of the packages and the project URL. Over time, I’ve accumulated a couple of scripts which replace placeholders in template projects by the new projects name. In the last couple of weeks, I’ve converted these scripts into a proper Python project itself. The project is called GiTemplet, a conctenation of Git and template because it takes Git repositories as templates.

What could GiTemplet do for you?

First of all, GiTemplet is a super simple command line tool. In it’s basic form,


it clones the repository into a temporary directory and replaces the strings {{ PN }} or {{ project_name }} by the given project name. Internally, the replacement is done using the jinja2 template engine. The generated files are copied to the current working directory. This even works with file names.

Is there more?

For most project templates one would like to prompt for more parameters when instantiating a new project, for example, the author of the project.

This can be achieved by adding the manifest .gitemplet.yml to the template repository. Have a look at the manifest of the python project.

version: '1'

    ask: Author
    default: Frank Sauerburger

    ask: e-mail address
    default: frank@sauerburger.com

    ask: Repository URL

    ask: "Include an command-line tool?"
    q_type: bool
    default: false

    ask: "Name of command-line tool?"
    only: exec

    ask: "Which python version should be tested?"
    q_type: float
    nargs: '+'

When you instantiate a new project using this template,

$ gitemplet https://gitlab.sauerburger.com/templates/python.git \

the following things will happen:

  • GiTemplet will prompt for the author’s name. The default is my name.
  • GiTemplet will prompt for the author’s email address.
  • GiTemplet will prompt for the URL of the repository.
  • GiTemplet will ask if the project ships with command-line tool.
  • If yes and only then, GiTemplet will ask for the name of the command-line tool.
  • Finally, the GiTemplet will ask which Python versions should be supported. Multiple values are allowed. This information is used to setup a test CI job for every supported version.

Are there ready-to-use templates?

Yes, currently, there are public project templates for Python libraries and webpack projects using react and bootstrap. Checkout the templates group.

Ok, fine. How do I get it?

Simply run:

$ git clone https://gitlab.sauerburger.com/frank/gitemplet.git
$ cd gitemplet
$ python3 setup.py