loaders

package
v0.0.0-...-4d051fd Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilesystemLoader

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

FilesystemLoader represents a local filesystem loader with basic BaseDirectory capabilities. The access to the local filesystem is unrestricted.

func MustNewFileSystemLoader

func MustNewFileSystemLoader(root string) *FilesystemLoader

MustNewFileSystemLoader creates a new FilesystemLoader instance and panics if there's any error during instantiation. The parameters are the same like NewFileSystemLoader.

func NewFileSystemLoader

func NewFileSystemLoader(root string) (*FilesystemLoader, error)

NewFileSystemLoader creates a new FilesystemLoader and allows templatesto be loaded from disk (unrestricted). If any base directory is given (or being set using SetBaseDir), this base directory is being used for path calculation in template inclusions/imports. Otherwise the path is calculated based relatively to the including template's path.

func (*FilesystemLoader) Get

func (fs *FilesystemLoader) Get(path string) (io.Reader, error)

Get reads the path's content from your local filesystem.

func (*FilesystemLoader) Path

func (fs *FilesystemLoader) Path(name string) (string, error)

Path resolves a filename relative to the base directory. Absolute paths are allowed. When there's no base dir set, the absolute path to the filename will be calculated based on either the provided base directory (which might be a path of a template which includes another template) or the current working directory.

func (*FilesystemLoader) SetBaseDir

func (fs *FilesystemLoader) SetBaseDir(path string) error

SetBaseDir sets the template's base directory. This directory will be used for any relative path in filters, tags and From*-functions to determine your template. See the comment for NewFileSystemLoader as well.

type Loader

type Loader interface {

	// Get returns an io.Reader where the template's content can be read from.
	Get(path string) (io.Reader, error)
}

TemplateLoader allows to implement a virtual file system.

type SandboxedFilesystemLoader

type SandboxedFilesystemLoader struct {
	*FilesystemLoader
}

SandboxedFilesystemLoader is still WIP.

func NewSandboxedFilesystemLoader

func NewSandboxedFilesystemLoader(root string) (*SandboxedFilesystemLoader, error)

NewSandboxedFilesystemLoader creates a new sandboxed local file system instance.

Jump to

Keyboard shortcuts

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