Documentation
¶
Overview ¶
Package native provides types to implement native variables, constants, functions, types and packages that can be imported or used as builtins in programs and templates.
Index ¶
- type CSS
- type CSSEnvStringer
- type CSSStringer
- type CombinedLoader
- type CombinedPackage
- type Declarations
- type DeclarationsPackage
- type Env
- type EnvStringer
- type HTML
- type HTMLEnvStringer
- type HTMLStringer
- type JS
- type JSEnvStringer
- type JSON
- type JSONEnvStringer
- type JSONStringer
- type JSStringer
- type Markdown
- type MarkdownEnvStringer
- type MarkdownStringer
- type Package
- type PackageLoader
- type Packages
- type UntypedBooleanConst
- type UntypedNumericConst
- type UntypedStringConst
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSSEnvStringer ¶
CSSEnvStringer is like CSSStringer where the CSS method takes an Env parameter.
type CSSStringer ¶
type CSSStringer interface {
CSS() CSS
}
CSSStringer is implemented by values that are not escaped in CSS context.
type CombinedLoader ¶
type CombinedLoader []PackageLoader
CombinedLoader combines multiple loaders into one loader.
type CombinedPackage ¶
type CombinedPackage []Package
CombinedPackage implements a Package by combining multiple packages into one package with name the name of the first package and as declarations the declarations of all packages.
The Lookup method calls the Lookup methods of each package in order and returns as soon as a package returns a not nil value.
func (CombinedPackage) DeclarationNames ¶
func (packages CombinedPackage) DeclarationNames() []string
DeclarationNames returns all declaration names in all packages.
func (CombinedPackage) Lookup ¶
func (packages CombinedPackage) Lookup(declName string) interface{}
Lookup calls the Lookup methods of each package in order and returns as soon as a combined package returns a declaration.
func (CombinedPackage) Name ¶
func (packages CombinedPackage) Name() string
Name returns the name of the first combined package.
type Declarations ¶
type Declarations map[string]interface{}
Declarations represents a set of variables, constants, functions, types and packages declarations and can be used for template globals and package declarations.
The key is the declaration's name and the element is its value
for a variable: a pointer to the value of the variable for a function: the function for a type: its reflect.Type value for a typed constant: its value as a string, boolean or numeric value for an untyped constant: an UntypedStringConst, UntypedBooleanConst or UntypedNumericConst value for a package: a Package value (used only for template globals)
type DeclarationsPackage ¶
type DeclarationsPackage struct {
// Package name.
PkgName string
// Package declarations.
Declarations Declarations
}
DeclarationsPackage implements Package given its name and Declarations.
func (*DeclarationsPackage) DeclarationNames ¶
func (p *DeclarationsPackage) DeclarationNames() []string
DeclarationNames returns all package declaration names.
func (*DeclarationsPackage) Lookup ¶
func (p *DeclarationsPackage) Lookup(declName string) interface{}
Lookup returns the declaration declName in the package or nil if no such declaration exists.
func (*DeclarationsPackage) Name ¶
func (p *DeclarationsPackage) Name() string
Name returns the package name.
type Env ¶
type Env interface {
// Context returns the context of the execution.
// It is the context passed as an option for execution.
Context() context.Context
// Exit exits the execution with the given status code. If the code is not
// zero, the execution returns a scriggo.ExitError error with this code.
// Deferred functions are not called and started goroutines are not
// terminated.
Exit(code int)
// Fatal exits the execution and then panics with value v. Deferred
// functions are not called and started goroutines are not terminated.
Fatal(v interface{})
// FilePath returns the path, relative to the root, of the current
// executed file. If it is not called by the main goroutine, the
// returned value is not significant.
FilePath() string
// Print calls the print built-in function with args as argument.
Print(args ...interface{})
// Println calls the println built-in function with args as argument.
Println(args ...interface{})
// TypeOf is like reflect.TypeOf but if v has a Scriggo type it returns
// its Scriggo reflect type instead of the reflect type of the proxy.
TypeOf(v reflect.Value) reflect.Type
}
Env represents an execution environment.
Each execution creates an Env value. This value is passed as the first argument to calls to native functions and methods that have Env as the type of the first parameter.
type EnvStringer ¶
EnvStringer is like fmt.Stringer where the String method takes an native.Env parameter.
type HTMLEnvStringer ¶
HTMLEnvStringer is like HTMLStringer where the HTML method takes a native.Env parameter.
type HTMLStringer ¶
type HTMLStringer interface {
HTML() HTML
}
HTMLStringer is implemented by values that are not escaped in HTML context.
type JSEnvStringer ¶
JSEnvStringer is like JSStringer where the JS method takes an Env parameter.
type JSONEnvStringer ¶
JSONEnvStringer is like JSONStringer where the JSON method takes an Env parameter.
type JSONStringer ¶
type JSONStringer interface {
JSON() JSON
}
JSONStringer is implemented by values that are not escaped in JSON context.
type JSStringer ¶
type JSStringer interface {
JS() JS
}
JSStringer is implemented by values that are not escaped in JavaScript context.
type MarkdownEnvStringer ¶
MarkdownEnvStringer is like MarkdownStringer where the Markdown method takes a native.Env parameter.
type MarkdownStringer ¶
type MarkdownStringer interface {
Markdown() Markdown
}
MarkdownStringer is implemented by values that are not escaped in Markdown context.
type Package ¶
type Package interface {
// Name returns the package's name.
Name() string
// Lookup searches for an exported declaration, named declName, in the
// package. If the declaration does not exist, it returns nil.
//
// For a variable returns a pointer to the variable, for a function
// returns the function, for a type returns its reflect.Type value, for a
// typed constant returns its value and for an untyped constant returns a
// UntypedStringConst, UntypedBooleanConst or UntypedNumericConst value.
Lookup(declName string) interface{}
// DeclarationNames returns the exported declaration names in the package.
DeclarationNames() []string
}
Package represents a native package.
type PackageLoader ¶
PackageLoader represents a package loader; Load returns the native package with the given path.
If an error occurs it returns the error, if the package does not exist it returns a nil package.
type UntypedBooleanConst ¶
type UntypedBooleanConst bool
UntypedBooleanConst represents an untyped boolean constant.
type UntypedNumericConst ¶
type UntypedNumericConst string
UntypedNumericConst represents an untyped numeric constant.
type UntypedStringConst ¶
type UntypedStringConst string
UntypedStringConst represents an untyped string constant.