templater

package
v0.94.8 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultUseCase = "simple"

DefaultUseCase maps to the template tree root, which released CLI versions already generate from.

Variables

This section is empty.

Functions

func LanguagesFor added in v0.94.7

func LanguagesFor(fsys fs.FS, useCase string) ([]string, error)

LanguagesFor returns the languages the use case supports, in the order of languageOrder. A language is supported when its template tree exists under the use case's root, meaning the language directory itself for go and the shared subdirectory for python and typescript.

func PackageManagersFor added in v0.94.7

func PackageManagersFor(language string) []string

PackageManagersFor returns the package managers the language supports.

func Process

func Process(fsys fs.FS, srcDir, dstDir string, data Data) error

Process reads all files from the specified directory within the provided filesystem, executes them as text/templates with the provided data, and writes the results to the destination directory, preserving the directory structure. Files named POST_QUICKSTART.md are skipped and not copied to the destination.

func ProcessMultiSource added in v0.75.2

func ProcessMultiSource(fsys fs.FS, sel Selection, dstDir string, data Data) error

ProcessMultiSource processes templates from multiple source directories (shared + package-manager-specific). It first processes files from the shared directory, then overlays package-manager-specific files. The selection's use case picks the template root. The default use case reads from templates/; any other use case reads from templates/use-cases/USE_CASE/. Under that root, languages that support multiple package managers (python, typescript) expect:

  • shared directory: ROOT/LANG/shared/
  • package manager directory: ROOT/LANG/PACKAGE_MANAGER/

For languages with a single package manager (go), it falls back to the language root directory.

func ProcessPostQuickstart

func ProcessPostQuickstart(fsys fs.FS, srcDir string, data Data) (string, error)

ProcessPostQuickstart reads and processes the POST_QUICKSTART.md file from the template directory. Returns the processed content as a string, or empty string if the file doesn't exist.

func ProcessPostQuickstartMultiSource added in v0.75.2

func ProcessPostQuickstartMultiSource(fsys fs.FS, sel Selection, data Data) (string, error)

ProcessPostQuickstartMultiSource reads and processes the POST_QUICKSTART.md file from the package-manager-specific directory. The selection's use case picks the template root, as in ProcessMultiSource. For languages with multiple package managers, it looks in ROOT/LANG/PACKAGE_MANAGER/. For Go, it looks in the ROOT/go/ directory. Returns the processed content as a string, or empty string if the file doesn't exist.

func UseCases added in v0.94.7

func UseCases(fsys fs.FS) ([]string, error)

UseCases returns the selectable use cases. The default comes first, then the use cases found in the filesystem, sorted.

func Validate added in v0.94.7

func Validate(fsys fs.FS, sel Selection) error

Validate checks that the selection names an existing use case, a language that use case supports, and a package manager that language supports.

Types

type Data

type Data struct {
	Name           string
	PackageManager string
}

Data holds the template data passed to each file.

type Selection added in v0.94.7

type Selection struct {
	UseCase        string
	Language       string
	PackageManager string
}

Selection identifies one template to generate.

Jump to

Keyboard shortcuts

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