appboot templates.
Template is important concept of appboot. If you have used Helm, the template is very similar to Helm's Chart.
Template use template syntax and use {{.xxx}} to place placeholders for appboot parameters.
Template is divided into code and configuration two parts.
The template code that needs to be converted to project code, such as VUE template.
The configuration is stored in the template's appboot/appboot.yaml.
# appboot.yaml desc: Vue 3 + Typescript + Vite template parameters: - key: Hello type: string tip: hello string default: hello vue - key: Object type: select tip: object value options: - World - Vue - iOS - key: Temperature type: int tip: temperature value default: 27 min: 0 max: 35 - key: Possibilities type: float tip: possibilities value default: 0.6 min: 0 max: 1.0 scripts: before: - echo before vue after: - cd appboot && sh after.shThe configuration contains the following parts:
- desc: template description
- parameters: parameter list, currently supports
string, int, float, selectfour types.The
Nameis the default parameter, indicating the name of the project, not listed inparameters. - scripts: custom scripts
- before: The set of commands executed before the project is created.The current directory(pwd) is the location where appboot is executed.
- after: The set of commands to execute after the project is created. The current directory(pwd) is the root directory of the generated project.
When there are many templates, the templates can be grouped.
Add appboot.yaml to the template repository and specify groups, as shown below
groups: - id: Back-end Templates desc: Back-end templates templates: - id: GO-CMD desc: "golang command line tool template" - id: Front-end Templates desc: Front-end templates templates: - id: SwiftUI desc: "SwiftUI template" - id: VUE desc: "Vue 3 + Typescript + Vite template"The following takes VUE template as an example to explain the template.
Create a project using the appboot command line.
❯ appboot create Using config file: /Users/catchzeng/.appboot/config.yaml ✔ VUE Name: test Path: ~/Desktop/test Enter the parameters, if you need to use the default value, just press Enter. Hello: hello ✔ World Temperature: 30 Possibilities: 0.3 Parameters: map[Hello:hello Object:World Possibilities:0.3 Temperature:30] ✔ NO ✔ NO Running script before the app is created echo before vue before vue Creating folders Creating files Running script after the app is created cd appboot && sh after.sh ...... FinishThe {{.Name}} placeholder in the VUE template will be replaced with the Name parameter of appboot, and the same for other parameters.
If you created the project with appboot web, the configuration(appboot/appboot.yaml) will be rendered to the front end.
# appboot.yaml desc: Vue 3 + Typescript + Vite template parameters: - key: Hello type: string tip: hello string default: hello vue - key: Object type: select tip: object value options: - World - Vue - iOS - key: Temperature type: int tip: temperature value default: 27 min: 0 max: 35 - key: Possibilities type: float tip: possibilities value default: 0.6 min: 0 max: 1.0 scripts: before: - echo before vue after: - cd appboot && sh after.shThe scripts (scripts/before & scripts/after) will also be executed before and after the project is created.


