Documentation
¶
Index ¶
- Variables
- func ValidDirReaderPath(path string) bool
- type CSS
- type CSSEnvStringer
- type CSSStringer
- type CompilerError
- type Declarations
- type DirLimitedReader
- type DirReader
- type EnvStringer
- type FileReader
- type HTML
- type HTMLEnvStringer
- type HTMLStringer
- type JavaScript
- type JavaScriptEnvStringer
- type JavaScriptStringer
- type Language
- type LoadOptions
- type MapReader
- type PrintTypeError
- type RenderOptions
- type Template
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPath is returned from the Load function and a FileReader when // the path argument is not valid. ErrInvalidPath = errors.New("scriggo: invalid path") // ErrNotExist is returned from the Load function when the path does not // exist. ErrNotExist = errors.New("scriggo: path does not exist") // ErrReadTooLarge is returned from the Load function when a limit is // exceeded reading a path. ErrReadTooLarge = errors.New("scriggo: read too large") )
Functions ¶
func ValidDirReaderPath ¶
ValidDirReaderPath reports whether path is valid as name for DirReader and DirLimitedReader.
Types ¶
type CSSEnvStringer ¶
CSSEnvStringer is like CSSStringer where the CSS method takes a runtime.Env parameter.
type CSSStringer ¶
type CSSStringer interface {
CSS() string
}
CSSStringer is implemented by values that are not escaped in CSS context.
type CompilerError ¶
CompilerError represents an error returned by the compiler.
type Declarations ¶
type Declarations map[string]interface{}
Declarations.
func Builtins ¶
func Builtins() Declarations
type DirLimitedReader ¶
type DirLimitedReader struct {
// contains filtered or unexported fields
}
DirLimitedReader implements a FileReader that reads a source from files in a directory limiting the maximum file size and the total bytes read from all reads.
Use DirLimitedReader, instead of DirReader, when you do not have control of file sizes. As a Parser reads a file with a specific context only once, DirLimitedReader can be passed to a Parser to prevent it from allocating too much memory.
func NewDirLimitedReader ¶
func NewDirLimitedReader(dir string, maxFile, maxTotal int) *DirLimitedReader
NewDirLimitedReader returns a DirLimitedReader that reads the file from directory dir limiting the file size to maxFile bytes and the total bytes read from all files to maxTotal. It panics if maxFile or maxTotal are negative.
type DirReader ¶
type DirReader string
DirReader implements a FileReader that reads the files in a directory.
To limit the size of read files, use DirLimitedReader instead.
type EnvStringer ¶
EnvStringer is like fmt.Stringer where the String method takes a runtime.Env parameter.
type FileReader ¶
FileReader is implemented by values that can read files of a template. name, if not absolute, is relative to the root of the template. If the file with the given name does not exist, it returns nil and an os not found error.
type HTMLEnvStringer ¶
HTMLEnvStringer is like HTMLStringer where the HTML method takes a runtime.Env parameter.
type HTMLStringer ¶
type HTMLStringer interface {
HTML() string
}
HTMStringer is implemented by values that are not escaped in HTML context.
type JavaScript ¶
type JavaScript string
JavaScript implements the JavaScriptStringer interface.
func (JavaScript) JavaScript ¶
func (js JavaScript) JavaScript() string
type JavaScriptEnvStringer ¶
JavaScriptEnvStringer is like JavaScriptStringer where the JavaScript method takes a runtime.Env parameter.
type JavaScriptStringer ¶
type JavaScriptStringer interface {
JavaScript() string
}
JavaScriptStringer is implemented by values that are not escaped in JavaScript context.
type LoadOptions ¶
type LoadOptions struct {
DisallowGoStmt bool
TreeTransformer func(*ast.Tree) error // if not nil transforms tree after parsing.
// Builtins declares constants, types, variables and functions that are
// accessible from the code in the template.
Builtins Declarations
// Loader is a package loader that makes precompiled packages available in
// the template through the 'import' statement.
//
// Note that an import statement refers to a precompiled package read from
// the Loader if its path has no extension.
//
// {% import "my/package" %} Import a precompiled package.
// {% import "my/file.html %} Import a template file.
//
Loader scriggo.PackageLoader
}
type MapReader ¶
MapReader implements a FileReader where sources are read from a map. Map keys are the file names. If a name is present both relative and absolute, the file of the absolute one is returned.
type PrintTypeError ¶
type PrintTypeError struct {
// contains filtered or unexported fields
}
func (PrintTypeError) Error ¶
func (err PrintTypeError) Error() string
func (PrintTypeError) RuntimeError ¶
func (err PrintTypeError) RuntimeError()
type RenderOptions ¶
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
func Load ¶
func Load(name string, files FileReader, lang Language, options *LoadOptions) (*Template, error)
Load loads a template given its file name. Load calls the method ReadFile of files to read the files of the template.
func (*Template) Disassemble ¶
Disassemble disassembles a template.
func (*Template) MustRender ¶
func (t *Template) MustRender(out io.Writer, vars map[string]interface{}, options *RenderOptions)
MustRender is like Render but panics if the rendering fails.