Templates¶
Overview¶
Templates in Rejigger are simply specially formatted folders containing a YAML file in the root folder named .rejig.yml (referred to as the template manifest) and a set of example source files that will be used to generate new projects from it.
Creating a template¶
You can create a simple template as follows
- create a new folder for your template in your home folder, say
~/mytemplate - create a new file named
.rejig.ymlin the empty folder with the following content:For details on the contents of this file, see here.versions: schema: 1.0 rejigger: 0.0.1 template: 1.0 template: args: - name: project_name description: Name of the source code project - Create another file named
README.mdalongside the manifest file, and put the following content in it:
Welcome to the {{project_name}} project!
That's it! Congratulations, you've just made your first template!
Using your new template¶
To test out your newly created template, do the following:
- Add the following lines to a file named
.rejigin your home folder:templates: - type: local source: ~/mytemplate name: MyTemplate - Next, run the following command:
rejig create ./MyNewProject MyTemplate - You should be prompted to enter a value for the
project_nameargument. Type any value that you like (ie: CoolApp) - Once the operation completes, you should see a new folder named
MyNewProject. In that folder you should see a file namedREADME.mdwith the contents "Welcome to the CoolApp project"!