Skip to content

Actions

Actions define how templates should be processed. They are stored in .tempo-files/actions/ as JSON files.

Example component action file (component.json):

json
[
  {
    "item": "file",
    "templateFile": "component/templ/component.templ.gotxt",
    "path": "{{ .GoPackage }}/{{ .ComponentName | goPackageName }}/{{ .ComponentName | goPackageName }}.templ"
  },
  {
    "item": "file",
    "templateFile": "component/assets/css/base.css.gotxt",
    "path": "{{ .AssetsDir }}/{{ .ComponentName | goPackageName }}/css/base.css"
  },
  {
    "item": "folder",
    "source": "component/assets/css/themes",
    "destination": "{{ .AssetsDir }}/{{ .ComponentName | goPackageName }}/css/themes"
  }
]

Each object defines a templating action:

KeyTypeDescription
itemfile/folderWhether the action is creating a file or a folder.
templateFilestringPath to the template file (only for file items).
pathstringOutput path for the generated file.
sourcestringSource folder (only for folder items).
destinationstringDestination folder for copied content.
skipIfExistsboolWhether to skip the file if it already exists.
forceboolWhether to overwrite existing files.

NOTE

When item is folder, all files inside the source folder will be processed and copied to the destination folder.

Variant actions (variant.json) follow the same structure but target a specific component’s variant subfolder.