dir

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStore

func NewStore(dir string) func() *Store

NewStore returns a DI-injectable constructor for a filesystem-backed template store rooted at dir. Only files with the ".html" extension are recognized from disk.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store reads templates from a directory on disk. File operations are sandboxed to the root directory via os.Root. An in-memory overlay handles programmatic registrations via Register and RegisterFS.

func (*Store) Close

func (s *Store) Close() error

Close releases the os.Root handle if it was opened.

func (*Store) Get

func (s *Store) Get(_ context.Context, name string) ([]byte, error)

Get returns the raw template content by name. Checks the in-memory overlay first, then falls back to disk.

func (*Store) List

func (s *Store) List(_ context.Context) ([]string, error)

List returns all available template names from both disk and the overlay, sorted and deduplicated.

func (*Store) Register

func (s *Store) Register(_ context.Context, name string, content []byte) error

Register adds or replaces a template in the in-memory overlay.

func (*Store) RegisterFS

func (s *Store) RegisterFS(ctx context.Context, fsys fs.FS) error

RegisterFS walks an fs.FS and registers every .html file found into the in-memory overlay.

Jump to

Keyboard shortcuts

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