Templates¶
The CLI has in-built support for using custom cookiecutter templates to create new projects in your workspace.
Template path¶
Given a templates/
directory contains some templates:
WORKSPACE_ROOT/
templates/
library-template/
application-template/
workspace.json
Make these templates available by adding the directory to the template path:
Tip
Any templates added to the directory above will automatically be available to the workspace.
Inspect the available templates with:
Info
Multiple directories can be added to the template path. To inspect the current template path, use workspace info
.
Using templates¶
Available templates can be used to create a new projects:
Tip
Ensure cookiecutter is installed with pip install workspace-cli[cookiecutter]
.
Default variables¶
Some additional variables can be automatically made available to project templates:
{{ workspace_project_path }}
is the relative path of the project from the workspace root.{{ workspace_project_name }}
is the name of the project in the workspace.
To make these available, include them in the template's cookiecutter.json
file, e.g.
{
"workspace_project_path": null,
"workspace_project_name": null
}
Warning
Encoding these in a project creates coupling between the project and the workspace.