...
Panel | ||||
---|---|---|---|---|
|
Prerequisites
It is assumed the VSCode Plugin and uip-cli version 2.0.0 are installed.
The development environment will be WSL (Windows Subsystem for Linux), however, it could be any of the supported platforms. The tutorial assumes a folder called demo_template
has been opened in VSCode.
Introduction
The custom, starter template that we will create is a contrived example, but it sufficiently covers all the features and its usefulness.
Step 1 - Create the Initial Template
To create a custom starter template, we will first make use of the built-in ue-task
template. Open up the terminal to the demo_template
folder and run
...
Code Block |
---|
demo_template/ ├── .uip │ └── config │ └── uip.yml ├── __init__.py ├── requirements.txt ├── setup.cfg ├── setup.py ├── src │ ├── __init__.py │ ├── extension.py │ ├── extension.yml │ └── templates │ └── template.json └── template_config.yml |
Step 2 - Configuring the Initial Template
To make the template configurable, add the following content below to template_config.yml
:
...
On line 19, a variable called my_msg
is defined with the value of "{{ msg }}"
. This is Jinja2 syntax that will eventually be replaced with the specified value for msg
(or the default, if they don’t specify anything) during initialization time.
On lines 26 31 and 2934, the message was changed to print the value of my_msg
.
...
On line 86 of the snippet above, the value of logLevel
was changed from Inherited
to {{ log_level | title }}
. Once again, this is Jinja2 syntax that will eventually be replaced with the specified value of log_level
(or the default, if nothing is specified). Additionally, the built-intitle
filter is applied to the value of log_level
. This will ensure values like trACe
end up as Trace
(first letter capitalized and everything else lowercase) as required by template.json
.
Step 3 - Packaging the Initial Template
Although the example is a bit contrived, we have managed to create a fully-functional customized template.
...
Code Block |
---|
Archive: example_template.zip Length Date Time Name --------- ---------- ----- ---- 0 2023-04-04 15:37 __init__.py 306 2023-04-04 15:37 requirements.txt 43 2023-04-05 11:03 setup.cfg 12088 2023-04-05 11:03 setup.py 0 2023-04-05 11:03 src/ 1723 2023-04-05 11:03 src/extension.py 221 2023-04-05 11:03 src/extension.yml 0 2023-04-05 11:03 src/templates/ 3278 2023-04-05 11:09 src/templates/template.json 0 2023-04-04 15:37 src/__init__.py 349 2023-04-05 11:05 template_config.yml --------- ------- 18008 11 files |