template

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 1 Imported by: 0

README

gas/template

Test Go Reference Go Version License

Part of the Gas monorepo · Documentation · All modules

Template storage for the Gas framework. Holds raw template content so that rendering, in gas/ui or gas/email, stays decoupled from where templates live.

Implements gas.TemplateProvider.

go get github.com/gasmod/gas/template
gas.WithSingletonService[gas.TemplateProvider](templatefs.NewStore(os.DirFS("templates"))),

db.NewStore() needs gas.DatabaseProvider, gas.Logger and gas.MigrationManager. The others need nothing; dir and fs return a constructor you call yourself.

Package Use case
template/memory Development, tests, ephemeral content
template/dir A directory on disk, with an in-memory overlay
template/fs Read-only over any fs.FS, including embed.FS
template/db Persistent and multi-instance: PostgreSQL, MySQL, SQLite
template/composite Chain providers: write to the first, read through all
template/templatetest Recording mock of gas.TemplateProvider

Documentation

The full guide, with configuration, testing, and worked examples, is on the docs site. This README is deliberately a signpost: keeping a second copy here is how the docs drifted before.

License

MIT

Documentation

Overview

Package template provides template storage and retrieval for the Gas ecosystem with in-memory, directory, database, filesystem, and composite backends in the memory, dir, db, fs, and composite sub-packages.

See the module README for usage examples and design rationale.

SPDX-License-Identifier: MIT

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTemplateNotFound is returned by Get when the requested template
	// does not exist.
	ErrTemplateNotFound = errors.New("template: not found")

	// ErrReadOnly is returned by Register and RegisterFS on read-only
	// providers (e.g. the fs backend). Wrap such providers in a composite
	// store with a writable provider if mutation is required.
	ErrReadOnly = errors.New("template: read-only provider")
)

Sentinel errors returned by TemplateProvider implementations.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the given error is an ErrTemplateNotFound. Useful for callers that need to distinguish "not found" from other errors.

Types

This section is empty.

Directories

Path Synopsis
db
Package fs provides a read-only template store backed by an fs.FS, suitable for use with embed.FS or any other fs.FS implementation.
Package fs provides a read-only template store backed by an fs.FS, suitable for use with embed.FS or any other fs.FS implementation.
internal
Package templatetest provides a mock implementation of gas.TemplateProvider for use in tests.
Package templatetest provides a mock implementation of gas.TemplateProvider for use in tests.

Jump to

Keyboard shortcuts

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