Documentation ¶
Index ¶
- Constants
- Variables
- func NewCompiledTemplateMultiError(err error, loader CompiledTemplateLoader) error
- type Ancestors
- type CompiledTemplate
- func (e *CompiledTemplate) Code() []TemplateLine
- func (e *CompiledTemplate) CodeAsString() string
- func (e *CompiledTemplate) CodeAtLine(pos *filepos.Position) *TemplateLine
- func (e *CompiledTemplate) DebugCodeAsString() string
- func (e *CompiledTemplate) Eval(thread *starlark.Thread, loader CompiledTemplateLoader) (starlark.StringDict, interface{}, error)
- func (e *CompiledTemplate) TplReplaceNode(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- type CompiledTemplateError
- type CompiledTemplateErrorPosition
- type CompiledTemplateLoader
- type CompiledTemplateMultiError
- type EvaluationCtx
- func (e *EvaluationCtx) RootNode() interface{}
- func (e *EvaluationCtx) RootNodeAsStarlarkValue() starlark.Value
- func (e *EvaluationCtx) TplCollectNodeAnnotation(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (e *EvaluationCtx) TplReplace(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (e *EvaluationCtx) TplSetNode(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (e *EvaluationCtx) TplStartNode(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (e *EvaluationCtx) TplStartNodeAnnotation(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- type EvaluationCtxDialect
- type EvaluationCtxDialectName
- type EvaluationCtxDialects
- type EvaluationNode
- type Instruction
- type InstructionOp
- type InstructionSet
- func (is *InstructionSet) NewCode(code string) Instruction
- func (is *InstructionSet) NewEndCtx() Instruction
- func (is *InstructionSet) NewEndCtxNone() Instruction
- func (is *InstructionSet) NewSetCtxType(dialect EvaluationCtxDialectName) Instruction
- func (is *InstructionSet) NewSetNode(nodeTag NodeTag) Instruction
- func (is *InstructionSet) NewSetNodeValue(nodeTag NodeTag, code string) Instruction
- func (is *InstructionSet) NewStartCtx(dialect EvaluationCtxDialectName) Instruction
- func (is *InstructionSet) NewStartNode(nodeTag NodeTag) Instruction
- func (is *InstructionSet) NewStartNodeAnnotation(nodeTag NodeTag, ann structmeta.Annotation) Instruction
- type NodeAnnotation
- type NodeAnnotations
- func (as NodeAnnotations) Args(name structmeta.AnnotationName) starlark.Tuple
- func (as NodeAnnotations) DeepCopy() NodeAnnotations
- func (as NodeAnnotations) DeepCopyAsInterface() interface{}
- func (as NodeAnnotations) DeleteNs(ns structmeta.AnnotationNs)
- func (as NodeAnnotations) Has(name structmeta.AnnotationName) bool
- func (as NodeAnnotations) Kwargs(name structmeta.AnnotationName) []starlark.Tuple
- type NodeTag
- type Nodes
- type NoopCompiledTemplateLoader
- func (l NoopCompiledTemplateLoader) FindCompiledTemplate(_ string) (*CompiledTemplate, error)
- func (l NoopCompiledTemplateLoader) ListData(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (l NoopCompiledTemplateLoader) Load(thread *starlark.Thread, module string) (starlark.StringDict, error)
- func (l NoopCompiledTemplateLoader) LoadData(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- type ProgramAST
- type SourceLine
- type TemplateLine
Constants ¶
View Source
const ( AnnotationComment structmeta.AnnotationName = "comment" AnnotationCode structmeta.AnnotationName = "template/code" AnnotationValue structmeta.AnnotationName = "template/value" )
Variables ¶
View Source
var (
NodeTagRoot = NodeTag{-100}
)
Functions ¶
func NewCompiledTemplateMultiError ¶
func NewCompiledTemplateMultiError(err error, loader CompiledTemplateLoader) error
Types ¶
type Ancestors ¶
type Ancestors struct {
// contains filtered or unexported fields
}
func NewAncestors ¶
func (Ancestors) FindCommonParentTag ¶
func (Ancestors) FindParentTag ¶
type CompiledTemplate ¶
type CompiledTemplate struct {
// contains filtered or unexported fields
}
func NewCompiledTemplate ¶
func NewCompiledTemplate(name string, code []TemplateLine, instructions *InstructionSet, nodes *Nodes, evalDialects EvaluationCtxDialects) *CompiledTemplate
func (*CompiledTemplate) Code ¶
func (e *CompiledTemplate) Code() []TemplateLine
func (*CompiledTemplate) CodeAsString ¶
func (e *CompiledTemplate) CodeAsString() string
func (*CompiledTemplate) CodeAtLine ¶
func (e *CompiledTemplate) CodeAtLine(pos *filepos.Position) *TemplateLine
func (*CompiledTemplate) DebugCodeAsString ¶
func (e *CompiledTemplate) DebugCodeAsString() string
func (*CompiledTemplate) Eval ¶
func (e *CompiledTemplate) Eval(thread *starlark.Thread, loader CompiledTemplateLoader) ( starlark.StringDict, interface{}, error)
type CompiledTemplateError ¶
type CompiledTemplateError struct { Positions []CompiledTemplateErrorPosition Msg string }
type CompiledTemplateErrorPosition ¶
type CompiledTemplateErrorPosition struct { Filename string ContextName string TemplateLine *TemplateLine }
type CompiledTemplateLoader ¶
type CompiledTemplateLoader interface { FindCompiledTemplate(string) (*CompiledTemplate, error) Load(*starlark.Thread, string) (starlark.StringDict, error) LoadData(*starlark.Thread, *starlark.Builtin, starlark.Tuple, []starlark.Tuple) (starlark.Value, error) ListData(*starlark.Thread, *starlark.Builtin, starlark.Tuple, []starlark.Tuple) (starlark.Value, error) }
type CompiledTemplateMultiError ¶
type CompiledTemplateMultiError struct {
// contains filtered or unexported fields
}
func (CompiledTemplateMultiError) Error ¶
func (e CompiledTemplateMultiError) Error() string
type EvaluationCtx ¶
type EvaluationCtx struct {
// contains filtered or unexported fields
}
func (*EvaluationCtx) RootNode ¶
func (e *EvaluationCtx) RootNode() interface{}
func (*EvaluationCtx) RootNodeAsStarlarkValue ¶
func (e *EvaluationCtx) RootNodeAsStarlarkValue() starlark.Value
func (*EvaluationCtx) TplCollectNodeAnnotation ¶
func (e *EvaluationCtx) TplCollectNodeAnnotation( thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
args(args..., kwargs...)
func (*EvaluationCtx) TplReplace ¶
func (*EvaluationCtx) TplSetNode ¶
func (e *EvaluationCtx) TplSetNode(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
args(nodeTag, value Value)
type EvaluationCtxDialect ¶
type EvaluationCtxDialect interface { PrepareNode(parentNode EvaluationNode, val EvaluationNode) error Replace(parentNodes []EvaluationNode, val interface{}) error ShouldWrapRootValue(val interface{}) bool WrapRootValue(val interface{}) interface{} }
type EvaluationCtxDialectName ¶
type EvaluationCtxDialectName string
type EvaluationCtxDialects ¶
type EvaluationCtxDialects map[EvaluationCtxDialectName]EvaluationCtxDialect
type EvaluationNode ¶
type Instruction ¶
type Instruction struct {
// contains filtered or unexported fields
}
func (Instruction) AsString ¶
func (i Instruction) AsString() string
func (Instruction) Op ¶
func (i Instruction) Op() InstructionOp
func (Instruction) WithDebug ¶
func (i Instruction) WithDebug(info string) Instruction
type InstructionOp ¶
type InstructionOp struct {
Name string
}
func (InstructionOp) WithArgs ¶
func (op InstructionOp) WithArgs(args ...string) Instruction
type InstructionSet ¶
type InstructionSet struct { SetCtxType InstructionOp StartCtx InstructionOp EndCtx InstructionOp StartNodeAnnotation InstructionOp CollectNodeAnnotation InstructionOp StartNode InstructionOp SetNode InstructionOp ReplaceNode InstructionOp }
func NewInstructionSet ¶
func NewInstructionSet() *InstructionSet
func (*InstructionSet) NewCode ¶
func (is *InstructionSet) NewCode(code string) Instruction
func (*InstructionSet) NewEndCtx ¶
func (is *InstructionSet) NewEndCtx() Instruction
func (*InstructionSet) NewEndCtxNone ¶
func (is *InstructionSet) NewEndCtxNone() Instruction
func (*InstructionSet) NewSetCtxType ¶
func (is *InstructionSet) NewSetCtxType(dialect EvaluationCtxDialectName) Instruction
func (*InstructionSet) NewSetNode ¶
func (is *InstructionSet) NewSetNode(nodeTag NodeTag) Instruction
func (*InstructionSet) NewSetNodeValue ¶
func (is *InstructionSet) NewSetNodeValue(nodeTag NodeTag, code string) Instruction
func (*InstructionSet) NewStartCtx ¶
func (is *InstructionSet) NewStartCtx(dialect EvaluationCtxDialectName) Instruction
func (*InstructionSet) NewStartNode ¶
func (is *InstructionSet) NewStartNode(nodeTag NodeTag) Instruction
func (*InstructionSet) NewStartNodeAnnotation ¶
func (is *InstructionSet) NewStartNodeAnnotation(nodeTag NodeTag, ann structmeta.Annotation) Instruction
type NodeAnnotations ¶
type NodeAnnotations map[structmeta.AnnotationName]NodeAnnotation
TODO change to struct
func NewAnnotations ¶
func NewAnnotations(node EvaluationNode) NodeAnnotations
func (NodeAnnotations) Args ¶
func (as NodeAnnotations) Args(name structmeta.AnnotationName) starlark.Tuple
func (NodeAnnotations) DeepCopy ¶
func (as NodeAnnotations) DeepCopy() NodeAnnotations
func (NodeAnnotations) DeepCopyAsInterface ¶
func (as NodeAnnotations) DeepCopyAsInterface() interface{}
func (NodeAnnotations) DeleteNs ¶
func (as NodeAnnotations) DeleteNs(ns structmeta.AnnotationNs)
func (NodeAnnotations) Has ¶
func (as NodeAnnotations) Has(name structmeta.AnnotationName) bool
func (NodeAnnotations) Kwargs ¶
func (as NodeAnnotations) Kwargs(name structmeta.AnnotationName) []starlark.Tuple
type NodeTag ¶
type NodeTag struct {
// contains filtered or unexported fields
}
func NewNodeTag ¶
type Nodes ¶
type Nodes struct {
// contains filtered or unexported fields
}
func (*Nodes) AddRootNode ¶
func (n *Nodes) AddRootNode(node EvaluationNode) NodeTag
type NoopCompiledTemplateLoader ¶
type NoopCompiledTemplateLoader struct{}
func (NoopCompiledTemplateLoader) FindCompiledTemplate ¶
func (l NoopCompiledTemplateLoader) FindCompiledTemplate(_ string) (*CompiledTemplate, error)
func (NoopCompiledTemplateLoader) Load ¶
func (l NoopCompiledTemplateLoader) Load( thread *starlark.Thread, module string) (starlark.StringDict, error)
type ProgramAST ¶
type ProgramAST struct {
// contains filtered or unexported fields
}
func NewProgramAST ¶
func NewProgramAST(f *syntax.File, instructions *InstructionSet) *ProgramAST
func (*ProgramAST) InsertTplCtxs ¶
func (r *ProgramAST) InsertTplCtxs()
type SourceLine ¶
type TemplateLine ¶
type TemplateLine struct { Instruction Instruction SourceLine *SourceLine }
func NewCodeFromBytes ¶
func NewCodeFromBytes(bs []byte, instructions *InstructionSet) []TemplateLine
func NewCodeFromBytesAtPosition ¶
func NewCodeFromBytesAtPosition(bs []byte, pos *filepos.Position, instructions *InstructionSet) []TemplateLine
func (*TemplateLine) Position ¶
func (l *TemplateLine) Position() *filepos.Position
Source Files ¶
Click to show internal directories.
Click to hide internal directories.