fs

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: 7 Imported by: 0

Documentation

Overview

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. For mutable storage, wrap this in a composite.Store with a writable provider such as memory.Store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStore

func NewStore(fsys fs.FS) func() *Store

NewStore returns a DI-injectable constructor for a read-only template store backed by fsys. Only files with the ".html" extension are recognized.

Types

type Store

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

Store reads templates from an fs.FS. Register and RegisterFS return template.ErrReadOnly — use composite.Store for mutability.

func (*Store) Get

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

Get returns the raw template content by name. Returns template.ErrTemplateNotFound if the file is not present.

func (*Store) List

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

List returns all template names from the fs.FS in sorted order.

func (*Store) Register

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

Register always returns template.ErrReadOnly.

func (*Store) RegisterFS

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

RegisterFS always returns template.ErrReadOnly.

Jump to

Keyboard shortcuts

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