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 simply want to synchronize CSS and JS assets with their .templ files, without using the full scaffolding features.
π₯ Use Cases for Standalone sync β
- 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 features.
π οΈ Example Standalone 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 .templ files, replacing the content between the guard markers.
π About Guard Markers β
tempo sync uses guard markers to locate where CSS and JS should be injected inside .templ files.
By default, it looks for:
/* [tempo] BEGIN - Do not edit! This section is auto-generated. */
/* [tempo] END */Only the text inside the brackets ([tempo]) is configurable β see guard_marker for details.
IMPORTANT
If no guard markers are present, tempo sync will skip the file, ensuring only intended sections are updated.