Standalone Sync
The sync command can be used independently of the scaffolding flow (define, new, register). All it requires is:
- A valid
tempo.yamlfile - A project folder structure matching the paths defined in
tempo.yaml - Guard markers in your
.templfiles to specify where assets should be injected
This makes tempo sync a great option for developers who want to synchronize CSS and JS assets with their .templ files, without using the full scaffolding features.
Use Cases
- Already have components but want automated asset injection
- Only need asset handling without using the full scaffolding flow
- Maintain existing folder structures while benefiting from tempo's synchronization
Example Workflow
Start by creating a Go module using the go mod init command.
Initialize
tempo.yaml:bashtempo initSet up your folders:
bash. ├── assets/ │ └── button/ │ └── button.css └── components/ └── button/ └── button.templPrepare .templ file with guard markers:
templpackage button var buttonCSSHandle = templ.NewOnceHandle() templ Button() { @buttonCSSHandle.Once() { <style type="text/css"> /* [tempo] BEGIN - Do not edit! This section is auto-generated. */ /* [tempo] END */ </style> }Run the sync command:
bashtempo syncResult:
CSS and JS are injected into the corresponding
.templfiles, replacing the content between the guard markers.
Guard Markers
tempo sync uses guard markers to locate injection points in .templ files. If no markers are found, the file is skipped.
See Guard Markers configuration for the default format and how to customize the marker label.