-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Templates
Custom templates are added by adding the project name to configs/project_types.json
and then creating a config for the project in configs
as well as the necessary files within templates
In this example we will create a template for a basic JavaScript
which prints the project name
First, modify the configs/project_types.json
file so that it includes the JavaScript
project name, like so:
{
"types": [
"RedbotCog",
"CppDll",
"SpigotPlugin",
"CppProject",
"JavaScript"
]
}
Second, create a config in the configs
directory. For this example it will be configs/JavaScript.json
.
An example project config is as follows:
{
"fields": [
{ "name": "projectName", "prompt": "Enter project name" },
],
"directories": [
{"path": "src"}
],
"files": [
{
"path": "src/main.js",
"template": "templates/main.js.tpl"
}
]
}
fields
is a list of placeholders and prompts that are asked to the user
directories
is a list of directories which get created by the project
files
is a list of files and the template that it uses
Third, create a template in the templates
directory. For this example it will be configs/main.js.tpl
.
An example template is as follows:
console.log("{projectName}");
The {projectName} placeholder is the same placeholder name from the project config file that we created earlier