Step 3: Add templates
Now that you have added some data models to drive template development, you can start writing templates.
Selection of the boilerplate/channel
Go to the graphical interface (command
hpf serve). Click on the
Boilerplates tab and select the previously created boilerplate. Click on
List of templates
You are now on this page:
The left sidebar shows all the templates available in your channel by organizing them in folders. On the right, an overview of the templates available in the folder selected on the left.
Adding a template
New path below a folder and enter a file path to create a new template.
You can add
/ in the template name to create its parent folders:
Dynamic template name
You can create a dynamic template name based on the model name:
If you have three models:
user profile and
listing, then this template will spawn three files:
The available cases are:
User profile(for the original name)
Dynamic names only work for templates of type
Change the name of a template
Click on the name in the left part and change it.
Delete a template
Hover over the name of the template in the left bar and click on the "delete" icon.
Choose the template engine
Several template engines are available.
Choose the input type
A template can receive as input one data model or all data models.
During generation, if set to
one model, the template will be called once for each data model. Therefore, it will generate one file for each data model.
If it is set as
all models, the template will be called once for all data models. It will then produce a single file.
To access the template editor, hover over a template in the list on the right and click on
On the left side is the template code, which you can edit. On the right, a preview of the rendering of the template for the selected data model.
Also, in the navigation bar is the path to the template and the path to the generated file.
You can directly change the template path in the navigation bar.
It is possible to automatically generate the target files when you save your template by clicking on the hammer icon.
The selection of data models is only available for templates of type