Template
Morph has a template facility to make writing SQL and Python code easier. Two types of templates exist.
Built-in Template
When the source code is opened on the workspace, a standard template created by the Morph team can be seen in the sidebar on the right. This template acts as a snippet of the Morph framework and by copying it you can immediately start implementing the analysis part.
If you have any requests for templates, please do not hesitate to request them from shibata@morphdb.io
!
Custom Template
In the templates
folder, user-defined template files can be created and managed.
New files can be created from the created templates with the morph create
command. You can also search for them with the morph search
command.
Steps to create a template
(Step 1) Create template files
Template files are created under the templates directory.
The following placeholders can be defined during creation. (The values defined in the placeholders can be specified in the morph create command options described below, which will create the file with the replacements).
${MORPH_NAME}
: replaced by the template name (old alias). (Specified by the--name
option of themorph create
command).${MORPH_DESCRIPTION}
: replaced by the template description. (Specified by the--description
option of themorph create
command)
E.g:
(Step 2) Edit template.yaml
Edit template.yaml directly under the templates folder, see example below for Syntax.
※The src can be defined as the full path or relative to template.yaml.
E.g:
(Step 3) Compile
You can check the validity of template.yaml with the following command. Once you have created the template file and even edited template.yaml, hit the following command from the VS Code terminal.
How to use templates
The templates you set up can be used in the menu on the right-hand side of the workspace or when creating a new canvas in the canvas.
Select from the list of templates
Select from canvas
How to use templates from the CLI
It can be created with the following command:
※The <template name>
is the name defined in template.yaml. Or by specifying the name returned by Template API, You can also use a global template.