FilesystemLoader represents a local filesystem loader with basic BaseDirectory capabilities. The access to the local filesystem is unrestricted.
type FilesystemLoader struct {
// contains filtered or unexported fields
}
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(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 (fs *FilesystemLoader) Get(path string) (io.Reader, error)
Get reads the path's content from your local filesystem.
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 (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.
TemplateLoader allows to implement a virtual file system.
type Loader interface { // Get returns an io.Reader where the template's content can be read from. Get(path string) (io.Reader, error) }
SandboxedFilesystemLoader is still WIP.
type SandboxedFilesystemLoader struct { *FilesystemLoader }
func NewSandboxedFilesystemLoader(root string) (*SandboxedFilesystemLoader, error)
NewSandboxedFilesystemLoader creates a new sandboxed local file system instance.