import "github.com/CloudyKit/jet"
constructors.go default.go eval.go func.go lex.go loader.go node.go parse.go template.go
IsEmptyTree reports whether this tree (node) is empty of everything but space.
ActionNode holds an action (something bounded by delimiters). Control actions have their own nodes; ActionNode represents simple ones such as field evaluations and parenthesized pipelines.
func (a *ActionNode) String() string
type AdditiveExprNode struct {
// contains filtered or unexported fields
}
AdditiveExprNode represents an add or subtract expression ex: expression ( '+' | '-' ) expression
type Arguments struct {
// contains filtered or unexported fields
}
Arguments holds the arguments passed to jet.Func.
Get gets an argument by index.
NumOfArguments returns the number of arguments
Panicf panics with formatted error message.
RequireNumOfArguments panics if the number of arguments is not in the range specified by min and max. In case there is no minimum pass -1, in case there is no maximum pass -1 respectively.
Runtime get the Runtime context
type BlockNode struct { NodeBase //The line number in the input. Deprecated: Kept for compatibility. Name string //The name of the template (unquoted). Parameters *BlockParameterList Expression Expression //The command to evaluate as dot for the template. List *ListNode Content *ListNode }
BlockNode represents a {{block }} action.
type BlockParameter struct { Identifier string Expression Expression }
type BlockParameterList struct { NodeBase List []BlockParameter }
func (bplist *BlockParameterList) Param(name string) (Expression, int)
func (bplist *BlockParameterList) String() (str string)
BoolNode holds a boolean constant.
type BranchNode struct { NodeBase Set *SetNode Expression Expression List *ListNode ElseList *ListNode }
BranchNode is the common representation of if, range, and with.
func (b *BranchNode) String() string
type CallExprNode struct { NodeBase BaseExpr Expression Args []Expression }
CallExprNode represents a call expression ex: expression '(' (expression (',' expression)* )? ')'
func (s *CallExprNode) String() string
ChainNode holds a term followed by a chain of field accesses (identifier starting with '.'). The names may be chained ('.x.y'). The periods are dropped from each ident.
Add adds the named field (which should start with a period) to the end of the chain.
type CommandNode struct { NodeBase Call bool BaseExpr Expression Args []Expression }
CommandNode holds a command (a pipeline inside an evaluating action).
func (c *CommandNode) String() string
type ComparativeExprNode struct {
// contains filtered or unexported fields
}
ComparativeExprNode represents a comparative expression ex: expression ( '==' | '!=' ) expression
FieldNode holds a field (identifier starting with '.'). The names may be chained ('.x.y'). The period is dropped from each ident.
Func function implementing this type is called directly, which is faster than calling through reflect. If a function is being called many times in the execution of a template, you may consider implementing a wrapper for that function implementing a Func.
IdentifierNode holds an identifier.
func (i *IdentifierNode) String() string
type IfNode struct { BranchNode }
IfNode represents an {{if}} action and its commands.
type IncludeNode struct { NodeBase Name Expression Expression Expression }
IncludeNode represents a {{include }} action.
func (t *IncludeNode) String() string
type IndexExprNode struct { NodeBase Base Expression Index Expression }
func (s *IndexExprNode) String() string
ListNode holds a sequence of nodes.
type Loader interface { // Open opens the underlying reader with template content. Open(name string) (io.ReadCloser, error) // Exists checks for template existence and returns full path. Exists(name string) (string, bool) }
Loader is a minimal interface required for loading templates.
type LogicalExprNode struct {
// contains filtered or unexported fields
}
LogicalExprNode represents a boolean expression, 'and' or 'or' ex: expression ( '&&' | '||' ) expression
type MultiplicativeExprNode struct {
// contains filtered or unexported fields
}
MultiplicativeExprNode represents a multiplication, division, or module expression ex: expression ( '*' | '/' | '%' ) expression
NilNode holds the special identifier 'nil' representing an untyped nil constant.
type Node interface { Type() NodeType String() string Position() Pos // contains filtered or unexported methods }
NodeType identifies the type of a parse tree node.
const ( NodeText NodeType = iota //Plain text. NodeAction //A non-control action such as a field evaluation. NodeChain //A sequence of field accesses. NodeCommand //An element of a pipeline. NodeField //A field or method name. NodeIdentifier //An identifier; always a function name. NodeIf //An if action. NodeList //A list of Nodes. NodePipe //A pipeline of commands. NodeRange //A range action. //NodeWith //A with action. NodeBlock NodeInclude NodeYield NodeSet NodeString //A string constant. NodeNil //An untyped nil constant. NodeNumber //A numerical constant. NodeBool //A boolean constant. NodeAdditiveExpr NodeMultiplicativeExpr NodeComparativeExpr NodeNumericComparativeExpr NodeLogicalExpr NodeCallExpr NodeNotExpr NodeTernaryExpr NodeIndexExpr NodeSliceExpr )
Type returns itself and provides an easy default implementation for embedding in a Node. Embedded in all non-trivial Nodes.
type NotExprNode struct { NodeBase Expr Expression }
NotExprNode represents a negate expression ex: '!' expression
func (s *NotExprNode) String() string
type NumberNode struct { NodeBase IsInt bool //Number has an integral value. IsUint bool //Number has an unsigned integral value. IsFloat bool //Number has a floating-point value. IsComplex bool //Number is complex. Int64 int64 //The signed integer value. Uint64 uint64 //The unsigned integer value. Float64 float64 //The floating-point value. Complex128 complex128 //The complex value. Text string //The original textual representation from the input. }
NumberNode holds a number: signed or unsigned integer, float, or complex. The value is parsed and stored under all the types that can represent the value. This simulates in a small amount of code the behavior of Go's ideal constants.
func (n *NumberNode) String() string
type NumericComparativeExprNode struct {
// contains filtered or unexported fields
}
NumericComparativeExprNode represents a numeric comparative expression ex: expression ( '<' | '>' | '<=' | '>=' ) expression
type OSFileSystemLoader struct {
// contains filtered or unexported fields
}
OSFileSystemLoader implements Loader interface using OS file system (os.File).
func NewOSFileSystemLoader(paths ...string) *OSFileSystemLoader
NewOSFileSystemLoader returns an initialized OSFileSystemLoader.
func (l *OSFileSystemLoader) AddGopathPath(path string)
AddGopathPath adds a path located in the GOPATH. Example: l.AddGopathPath("github.com/CloudyKit/jet/example/views")
func (l *OSFileSystemLoader) AddPath(path string)
AddPath adds the path to the internal list of paths searched when loading templates.
func (l *OSFileSystemLoader) Exists(name string) (string, bool)
Exists checks if the template name exists by walking the list of template paths returns string with the full path of the template and bool true if the template file was found
func (l *OSFileSystemLoader) Open(name string) (io.ReadCloser, error)
Open opens a file from OS file system.
type PipeNode struct { NodeBase //The line number in the input. Deprecated: Kept for compatibility. Cmds []*CommandNode //The commands in lexical order. }
PipeNode holds a pipeline with optional declaration
Pos represents a byte position in the original input text from which this template was parsed.
type RangeNode struct { BranchNode }
RangeNode represents a {{range}} action and its commands.
Ranger a value implementing a ranger interface is able to iterate on his value and can be used directly in a range statement
Renderer any resulting value from an expression in an action that implements this interface will not be printed, instead, we will invoke his Render() method which will be responsible to render his self
RendererFunc func implementing interface Renderer
func (renderer RendererFunc) Render(r *Runtime)
type Runtime struct {
// contains filtered or unexported fields
}
Runtime this type holds the state of the execution of an template
Context returns the current context value
Resolve resolves a value from the execution context
Set sets variable ${name} in the current template scope
YieldBlock yields a block in the current context, will panic if the context is not available
YieldTemplate yields a template same as include
SafeWriter escapee func. Functions implementing this type will write directly into the writer, skipping the escape phase; use this type to create special types of escapee funcs.
type Set struct {
// contains filtered or unexported fields
}
Set is responsible to load,invoke parse and cache templates and relations every jet template is associated with one set. create a set with jet.NewSet(escapeeFn) returns a pointer to the Set
NewHTMLSet creates a new set, dirs is a list of directories to be searched for templates
NewHTMLSetLoader creates a new set with custom Loader
func NewSet(escapee SafeWriter, dirs ...string) *Set
NewSet creates a new set, dirs is a list of directories to be searched for templates
func NewSetLoader(escapee SafeWriter, loader Loader) *Set
NewSetLoader creates a new set with custom Loader
AddGlobal add or set a global variable into the Set
AddGopathPath add path based on GOPATH env to the lookup list, when loading a template the Set will look into the lookup list for the file matching the provided name.
AddPath add path to the lookup list, when loading a template the Set will look into the lookup list for the file matching the provided name.
Delims sets the delimiters to the specified strings. Parsed templates will inherit the settings. Not setting them leaves them at the default: {{ or }}.
Parse parses the template, this method will link the template to the set but not the set to
SetDevelopmentMode set's development mode on/off, in development mode template will be recompiled on every run
type SetNode struct { NodeBase Let bool IndexExprGetLookup bool Left []Expression Right []Expression }
SetNode represents a set action, ident( ',' ident)* '=' expression ( ',' expression )*
type SliceExprNode struct { NodeBase Base Expression Index Expression EndIndex Expression }
func (s *SliceExprNode) String() string
type StringNode struct { NodeBase Quoted string //The original text of the string, with quotes. Text string //The string, after quote processing. }
StringNode holds a string constant. The value has been "unquoted".
func (s *StringNode) String() string
type Template struct { Name string // name of the template represented by the tree. ParseName string // name of the top-level template during parsing, for error messages. Root *ListNode // top-level root of the tree. // contains filtered or unexported fields }
Template is the representation of a single parsed template.
Execute executes the template in the w Writer
func (t *Template) ExecuteI18N(translator Translator, w io.Writer, variables VarMap, data interface{}) (err error)
type TernaryExprNode struct { NodeBase Boolean, Left, Right Expression }
TernaryExprNod represents a ternary expression, ex: expression '?' expression ':' expression
func (s *TernaryExprNode) String() string
TextNode holds plain text.
type Translator interface { Msg(key, defaultValue string) string Trans(format, defaultFormat string, v ...interface{}) string }
func (scope VarMap) SetWriter(name string, v SafeWriter) VarMap
type YieldNode struct { NodeBase //The line number in the input. Deprecated: Kept for compatibility. Name string //The name of the template (unquoted). Parameters *BlockParameterList Expression Expression //The command to evaluate as dot for the template. Content *ListNode IsContent bool }
YieldNode represents a {{yield}} action
Path | Synopsis |
---|---|
jettest | |
loaders/httpfs | |
loaders/multi | |
utils | |
yield |
Package jet imports 20 packages (graph) and is imported by 39 packages. Updated 2019-10-04. Refresh now. Tools for package owners.