ast

package
Version: v0.0.0-...-4dafff4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2017 License: MIT Imports: 4 Imported by: 8

Documentation

Overview

Package ast contains definitions for the in-memory representation of a Soy template.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddNode

type AddNode struct{ BinaryOpNode }

type AndNode

type AndNode struct{ BinaryOpNode }

type AutoescapeType

type AutoescapeType int
const (
	AutoescapeUnspecified AutoescapeType = iota
	AutoescapeOn
	AutoescapeOff
	AutoescapeContextual
)

type BinaryOpNode

type BinaryOpNode struct {
	Name string
	Pos
	Arg1, Arg2 Node
}

func (*BinaryOpNode) Children

func (n *BinaryOpNode) Children() []Node

func (*BinaryOpNode) String

func (n *BinaryOpNode) String() string

type BoolNode

type BoolNode struct {
	Pos
	True bool
}

func (*BoolNode) String

func (b *BoolNode) String() string

type CallNode

type CallNode struct {
	Pos
	Name    string
	AllData bool
	Data    Node
	Params  []Node
}

func (*CallNode) Children

func (n *CallNode) Children() []Node

func (*CallNode) String

func (n *CallNode) String() string

type CallParamContentNode

type CallParamContentNode struct {
	Pos
	Key     string
	Content Node
	Kind    string
}

func (*CallParamContentNode) Children

func (n *CallParamContentNode) Children() []Node

func (*CallParamContentNode) String

func (n *CallParamContentNode) String() string

type CallParamValueNode

type CallParamValueNode struct {
	Pos
	Key   string
	Value Node
	Kind  string
}

func (*CallParamValueNode) Children

func (n *CallParamValueNode) Children() []Node

func (*CallParamValueNode) String

func (n *CallParamValueNode) String() string

type CssNode

type CssNode struct {
	Pos
	Expr   Node
	Suffix string
}

func (*CssNode) Children

func (n *CssNode) Children() []Node

func (*CssNode) String

func (n *CssNode) String() string

type DataRefExprNode

type DataRefExprNode struct {
	Pos
	NullSafe bool
	Arg      Node
}

func (*DataRefExprNode) Children

func (n *DataRefExprNode) Children() []Node

func (*DataRefExprNode) String

func (n *DataRefExprNode) String() string

type DataRefIndexNode

type DataRefIndexNode struct {
	Pos
	NullSafe bool
	Index    int
}

func (*DataRefIndexNode) String

func (n *DataRefIndexNode) String() string

type DataRefKeyNode

type DataRefKeyNode struct {
	Pos
	NullSafe bool
	Key      string
}

func (*DataRefKeyNode) String

func (n *DataRefKeyNode) String() string

type DataRefNode

type DataRefNode struct {
	Pos
	Key    string
	Access []Node
}

func (*DataRefNode) Children

func (n *DataRefNode) Children() []Node

func (*DataRefNode) String

func (n *DataRefNode) String() string

type DebuggerNode

type DebuggerNode struct {
	Pos
}

func (*DebuggerNode) String

func (n *DebuggerNode) String() string

type DivNode

type DivNode struct{ BinaryOpNode }

type ElvisNode

type ElvisNode struct{ BinaryOpNode }

type EqNode

type EqNode struct{ BinaryOpNode }

type FloatNode

type FloatNode struct {
	Pos
	Value float64
}

func (*FloatNode) String

func (n *FloatNode) String() string

type ForNode

type ForNode struct {
	Pos
	Var     string // without the leading $
	List    Node
	Body    Node
	IfEmpty Node
}

Note: - "For" node is required to have a range() call as the List - "Foreach" node is required to have a DataRefNode as the List

func (*ForNode) Children

func (n *ForNode) Children() []Node

func (*ForNode) String

func (n *ForNode) String() string

type FunctionNode

type FunctionNode struct {
	Pos
	Name string
	Args []Node
}

func (*FunctionNode) Children

func (n *FunctionNode) Children() []Node

func (*FunctionNode) String

func (n *FunctionNode) String() string

type GlobalNode

type GlobalNode struct {
	Pos
	Name string
	data.Value
}

func (*GlobalNode) String

func (n *GlobalNode) String() string

type GtNode

type GtNode struct{ BinaryOpNode }

type GteNode

type GteNode struct{ BinaryOpNode }

type IdentNode

type IdentNode struct {
	Pos
	Ident string // The ident's name.
}

func (*IdentNode) String

func (i *IdentNode) String() string

type IfCondNode

type IfCondNode struct {
	Pos
	Cond Node // nil if "else"
	Body Node
}

func (*IfCondNode) Children

func (n *IfCondNode) Children() []Node

func (*IfCondNode) String

func (n *IfCondNode) String() string

type IfNode

type IfNode struct {
	Pos
	Conds []*IfCondNode
}

func (*IfNode) Children

func (n *IfNode) Children() []Node

func (*IfNode) String

func (n *IfNode) String() string

type IntNode

type IntNode struct {
	Pos
	Value int64
}

func (*IntNode) String

func (n *IntNode) String() string

type LetContentNode

type LetContentNode struct {
	Pos
	Name string
	Body Node
}

func (*LetContentNode) Children

func (n *LetContentNode) Children() []Node

func (*LetContentNode) String

func (n *LetContentNode) String() string

type LetValueNode

type LetValueNode struct {
	Pos
	Name string
	Expr Node
}

func (*LetValueNode) Children

func (n *LetValueNode) Children() []Node

func (*LetValueNode) String

func (n *LetValueNode) String() string

type ListLiteralNode

type ListLiteralNode struct {
	Pos
	Items []Node
}

func (*ListLiteralNode) Children

func (n *ListLiteralNode) Children() []Node

func (*ListLiteralNode) String

func (n *ListLiteralNode) String() string

type ListNode

type ListNode struct {
	Pos
	Nodes []Node // The element nodes in lexical order.
}

ListNode holds a sequence of nodes.

func (*ListNode) Children

func (l *ListNode) Children() []Node

func (*ListNode) String

func (l *ListNode) String() string

type LiteralNode

type LiteralNode struct {
	Pos
	Body string
}

func (*LiteralNode) String

func (n *LiteralNode) String() string

type LogNode

type LogNode struct {
	Pos
	Body Node
}

func (*LogNode) Children

func (n *LogNode) Children() []Node

func (*LogNode) String

func (n *LogNode) String() string

type LtNode

type LtNode struct{ BinaryOpNode }

type LteNode

type LteNode struct{ BinaryOpNode }

type MapLiteralNode

type MapLiteralNode struct {
	Pos
	Items map[string]Node
}

func (*MapLiteralNode) Children

func (n *MapLiteralNode) Children() []Node

func (*MapLiteralNode) String

func (n *MapLiteralNode) String() string

type ModNode

type ModNode struct{ BinaryOpNode }

type MsgHtmlTagNode

type MsgHtmlTagNode struct {
	Pos
	Text []byte
}

func (*MsgHtmlTagNode) String

func (n *MsgHtmlTagNode) String() string

type MsgNode

type MsgNode struct {
	Pos
	ID      uint64
	Meaning string
	Desc    string
	Body    ParentNode // top-level children: RawTextNode, MsgPlaceholderNode, MsgPluralNode
}

MsgNode represents a localized message.

func (*MsgNode) Children

func (n *MsgNode) Children() []Node

func (*MsgNode) Placeholder

func (n *MsgNode) Placeholder(name string) *MsgPlaceholderNode

Placeholder returns a placeholder node with the given name within this message node. It requires placeholder names to have been calculated.

func (*MsgNode) String

func (n *MsgNode) String() string

type MsgPlaceholderNode

type MsgPlaceholderNode struct {
	Pos
	Name string
	Body Node
}

func (*MsgPlaceholderNode) Children

func (n *MsgPlaceholderNode) Children() []Node

func (*MsgPlaceholderNode) String

func (n *MsgPlaceholderNode) String() string

type MsgPluralCaseNode

type MsgPluralCaseNode struct {
	Pos
	Value int
	Body  ParentNode // top level children: RawTextNode, MsgPlaceholderNode
}

func (*MsgPluralCaseNode) Children

func (n *MsgPluralCaseNode) Children() []Node

func (*MsgPluralCaseNode) String

func (n *MsgPluralCaseNode) String() string

type MsgPluralNode

type MsgPluralNode struct {
	Pos
	VarName string
	Value   Node
	Cases   []*MsgPluralCaseNode
	Default ParentNode
}

func (*MsgPluralNode) Children

func (n *MsgPluralNode) Children() []Node

func (*MsgPluralNode) String

func (n *MsgPluralNode) String() string

type MulNode

type MulNode struct{ BinaryOpNode }

type NamespaceNode

type NamespaceNode struct {
	Pos
	Name       string
	Autoescape AutoescapeType
}

NamespaceNode registers the namespace of the soy file.

func (*NamespaceNode) String

func (c *NamespaceNode) String() string

type NegateNode

type NegateNode struct {
	Pos
	Arg Node
}

func (*NegateNode) Children

func (n *NegateNode) Children() []Node

func (*NegateNode) String

func (n *NegateNode) String() string

type Node

type Node interface {
	String() string // String returns the soy source representation of this node.
	Position() Pos  // byte position of start of node in full original input string
}

Node represents any singular piece of a soy template. For example, a sequence of raw text or a print tag.

type NotEqNode

type NotEqNode struct{ BinaryOpNode }

type NotNode

type NotNode struct {
	Pos
	Arg Node
}

func (*NotNode) Children

func (n *NotNode) Children() []Node

func (*NotNode) String

func (n *NotNode) String() string

type NullNode

type NullNode struct {
	Pos
}

func (*NullNode) String

func (s *NullNode) String() string

type OrNode

type OrNode struct{ BinaryOpNode }

type ParamDeclNode

type ParamDeclNode struct {
	Pos

	Optional bool
	Name     string
	Type     string
}

func (*ParamDeclNode) String

func (n *ParamDeclNode) String() string

type ParentNode

type ParentNode interface {
	Node
	Children() []Node
}

ParentNode is any Node that has descendent nodes. For example, the Children of a AddNode are the two nodes that should be added.

type Pos

type Pos int

Pos represents a byte position in the original input text from which this template was parsed. It is useful to construct helpful error messages.

func (Pos) Position

func (p Pos) Position() Pos

Position returns this position. It is implemented as a method so that Nodes may embed a Pos and fulfill this part of the Node interface for free.

type PrintDirectiveNode

type PrintDirectiveNode struct {
	Pos
	Name string
	Args []Node
}

func (*PrintDirectiveNode) Children

func (n *PrintDirectiveNode) Children() []Node

func (*PrintDirectiveNode) String

func (n *PrintDirectiveNode) String() string

type PrintNode

type PrintNode struct {
	Pos
	Arg        Node
	Directives []*PrintDirectiveNode
}

func (*PrintNode) Children

func (n *PrintNode) Children() []Node

func (*PrintNode) String

func (n *PrintNode) String() string

type RawTextNode

type RawTextNode struct {
	Pos
	Text []byte // The text; may span newlines.
}

func (*RawTextNode) String

func (t *RawTextNode) String() string

type SoyDocNode

type SoyDocNode struct {
	Pos
	Params []*SoyDocParamNode
}

func (*SoyDocNode) Children

func (n *SoyDocNode) Children() []Node

func (*SoyDocNode) String

func (n *SoyDocNode) String() string

type SoyDocParamNode

type SoyDocParamNode struct {
	Pos
	Name     string // e.g. "name"
	Optional bool
}

SoyDocParam represents a parameter to a soy template. e.g.

/**
 * Says hello to the person
 * @param name The name of the person to say hello to.
 */

func (*SoyDocParamNode) String

func (n *SoyDocParamNode) String() string

type SoyFileNode

type SoyFileNode struct {
	Name string
	Text string
	Body []Node
}

SoyFileNode represents a soy file.

func (SoyFileNode) Children

func (n SoyFileNode) Children() []Node

func (SoyFileNode) Position

func (n SoyFileNode) Position() Pos

func (SoyFileNode) String

func (n SoyFileNode) String() string

type StringNode

type StringNode struct {
	Pos
	Quoted string // e.g. 'hello\tworld'
	Value  string // e.g. hello	world
}

func (*StringNode) String

func (s *StringNode) String() string

type SubNode

type SubNode struct{ BinaryOpNode }

type SwitchCaseNode

type SwitchCaseNode struct {
	Pos
	Values []Node // len(Values) == 0 => default case
	Body   Node
}

func (*SwitchCaseNode) Children

func (n *SwitchCaseNode) Children() []Node

func (*SwitchCaseNode) String

func (n *SwitchCaseNode) String() string

type SwitchNode

type SwitchNode struct {
	Pos
	Value Node
	Cases []*SwitchCaseNode
}

func (*SwitchNode) Children

func (n *SwitchNode) Children() []Node

func (*SwitchNode) String

func (n *SwitchNode) String() string

type TemplateNode

type TemplateNode struct {
	Pos
	Name       string
	Body       *ListNode
	Autoescape AutoescapeType
	Private    bool
}

TemplateNode holds a template body.

func (*TemplateNode) Children

func (n *TemplateNode) Children() []Node

func (*TemplateNode) String

func (n *TemplateNode) String() string

type TernNode

type TernNode struct {
	Pos
	Arg1, Arg2, Arg3 Node
}

func (*TernNode) Children

func (n *TernNode) Children() []Node

func (*TernNode) String

func (n *TernNode) String() string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL