stack

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 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

This section is empty.

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 returns a cache of HTML page templates for an application, with added package and site templates.

The cache is built using the file organisation suggested by Let's Go by Alex Edwards: a page.tmpl file specifies the name and content of am 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.

Application template definitions override package templates of the same name. Similarly, site template definitions override application 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