stack

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package stack implements a single file system, StackFS, from a stack of file systems.

A file defined higher in the stack overrides any file of the same path and name lower in the stack. Typically the top FS holds site customisation, the next lower FS holds embedded files for application resources, with package resources at the bottom.

After initialisation, each Open request accesses just one file system. The implementation assumes that all the FS, except for the top one, hold a modest number of files. It also assumes that only the top FS may have files added after initialisation, and removing a file will not uncover one in a lower FS.

Index

Constants

This section is empty.

Variables

View Source
var TemplateNames = [3]string{"*.page.tmpl", "*.layout.tmpl", "*.partial.tmpl"}

TemplateNames specifies the file names for a cache of HTML templates using the file organisation suggested by Let's Go by Alex Edwards: a page.tmpl file specifies the name and content of an HTML page in the cache; a layout.tmpl file defines a common layout for a set of pages; partial.tmpl files define common content across multiple pages and layouts.

Functions

func NewFS

func NewFS(stack ...fs.FS) (fs.FS, error)

NewFS returns a combined file system for a stack of file systems (base first).

func NewTemplates

func NewTemplates(forPkgs []fs.FS, forApp fs.FS, forSite fs.FS, funcs template.FuncMap) (map[string]*template.Template, error)

NewTemplates is deprecated as too specific. Use NewTemplatesLayered instead.

func NewTemplatesLayered

func NewTemplatesLayered(funcs template.FuncMap, forPkgs []fs.FS, forLayers ...fs.FS) (map[string]*template.Template, error)

NewTemplatesLayered returns a cache of HTML page templates for an application, with added package and layer templates. Typically the layers are the application, app customisations, and site customisations.

Layer template definitions override package templates of the same name. Similarly, each layer's template definitions override preceding layer templates by name.

Types

type StackFS

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

func (StackFS) Open

func (sfs StackFS) Open(name string) (fs.File, error)

Open returns the interface to a named file in the stack.

Jump to

Keyboard shortcuts

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