template

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Globals = map[string]any{}

Globals is a map of template variables available in all Render calls. Built-in variables include ToolDir, RootDir, OS, and Arch. Packages can add their own globals (e.g., git package adds GitRoot).

To add custom variables:

template.Globals["Version"] = func() string { return "1.0.0" }
template.Globals["BuildTime"] = time.Now().Format(time.RFC3339)

Functions

func Render

func Render(template string, args ...map[string]any) string

Render processes a Go template string, substituting variables from Globals and any additional context maps provided. Variables can be values or functions (which are called during rendering).

Example:

Render("{{RootDir}}/.tool/{{OS}}_{{Arch}}")
Render("Hello {{.Name}}", map[string]any{"Name": "World"})

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL