jadeparser

package
v0.0.0-...-d40fe38 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyString = reflect.ValueOf("")

Functions

func InSlice

func InSlice(slice []string, value string) bool

func LineNumber

func LineNumber(source string, pos int) int

func NewParser

func NewParser(input string) *parser

func ObjToString

func ObjToString(val interface{}) string

Types

type BoolToken

type BoolToken struct {
	EmptyToken
	Value bool
}

func NewBoolToken

func NewBoolToken(value string) *BoolToken

func (*BoolToken) String

func (this *BoolToken) String() string

type CommentToken

type CommentToken struct {
	EmptyToken
	CommentType string
}

func NewCommentToken

func NewCommentToken(commentType string) *CommentToken

func (*CommentToken) String

func (this *CommentToken) String() string

type ContextStack

type ContextStack struct {
	// contains filtered or unexported fields
}

ContextStack is a stack of maps, used to track functions with context like for loops, mixins, etc

func NewContextStack

func NewContextStack() *ContextStack

NewContextStack

func (*ContextStack) AddLayer

func (this *ContextStack) AddLayer()

AddLayer

func (*ContextStack) DropLayer

func (this *ContextStack) DropLayer()

DropLayer

func (*ContextStack) Get

func (this *ContextStack) Get(name string) reflect.Value

Get

func (*ContextStack) GetOk

func (this *ContextStack) GetOk(name string) (value reflect.Value, ok bool)

GetOk get's a value from the stack with a bool indicating if the value was found or not.

func (*ContextStack) Set

func (this *ContextStack) Set(name string, value interface{})

Set

func (*ContextStack) SetGlobal

func (this *ContextStack) SetGlobal(name string, value reflect.Value)

SetGlobal Set a value on the global scope.

type EmptyToken

type EmptyToken struct {
	// contains filtered or unexported fields
}

func NewEmptyToken

func NewEmptyToken() *EmptyToken

func (*EmptyToken) Category

func (this *EmptyToken) Category() TokenCategory

func (*EmptyToken) Error

func (this *EmptyToken) Error() error

func (*EmptyToken) SetError

func (this *EmptyToken) SetError(err error)

func (*EmptyToken) String

func (this *EmptyToken) String() string

type ErrorToken

type ErrorToken struct {
	EmptyToken
}

func NewErrorToken

func NewErrorToken(err string) *ErrorToken

type EvalJade

type EvalJade struct {
	Loader TemplateLoader

	Extfunc map[string]reflect.Value

	Blocks   map[string]*jadePart
	Mixins   map[string]*jadePart
	Beautify bool
	Log      []string
	// contains filtered or unexported fields
}

func NewEvalJade

func NewEvalJade(wr io.Writer) *EvalJade

func (*EvalJade) Exec

func (this *EvalJade) Exec(parsedJade *TreeNode)

func (*EvalJade) RegisterFunction

func (this *EvalJade) RegisterFunction(name string, fn interface{})

func (*EvalJade) RenderFile

func (this *EvalJade) RenderFile(filename string)

func (*EvalJade) RenderString

func (this *EvalJade) RenderString(template string)

func (*EvalJade) SetData

func (this *EvalJade) SetData(data interface{})

func (*EvalJade) SetViewPath

func (this *EvalJade) SetViewPath(viewpath string)

type FuncToken

type FuncToken struct {
	EmptyToken
	Name       string
	Arguments  []*TreeNode
	Next       *FuncToken
	IsIdentity bool
	Index      *TreeNode
}

func NewFuncToken

func NewFuncToken(name string) *FuncToken

func NewIdentityToken

func NewIdentityToken(name string) *FuncToken

func (*FuncToken) AddArgument

func (this *FuncToken) AddArgument(arg *TreeNode)

func (*FuncToken) String

func (this *FuncToken) String() string

type Getter

type Getter interface {
	Get(string) reflect.Value
}

type GroupToken

type GroupToken struct {
	EmptyToken
	GroupType string
}

func NewGroupToken

func NewGroupToken(group string) *GroupToken

func (*GroupToken) String

func (this *GroupToken) String() string

type HtmlDocTypeToken

type HtmlDocTypeToken struct {
	EmptyToken
	Attributes []string
}

func NewHtmlDocTypeToken

func NewHtmlDocTypeToken() *HtmlDocTypeToken

func (*HtmlDocTypeToken) String

func (this *HtmlDocTypeToken) String() string

type HtmlTagToken

type HtmlTagToken struct {
	EmptyToken
	TagName     string
	Attributes  []*TreeNode
	SelfClosing bool
}

func NewHtmlTagToken

func NewHtmlTagToken(tagname string) *HtmlTagToken

func (*HtmlTagToken) AddAttribute

func (this *HtmlTagToken) AddAttribute(attr *TreeNode) *TreeNode

func (*HtmlTagToken) AddKeyValue

func (this *HtmlTagToken) AddKeyValue(key string, value *TreeNode) *TreeNode

func (*HtmlTagToken) SetClass

func (this *HtmlTagToken) SetClass(attr *TreeNode) *TreeNode

func (*HtmlTagToken) String

func (this *HtmlTagToken) String() string

type KeyValueToken

type KeyValueToken struct {
	EmptyToken
	Key   string
	Value *TreeNode
}

func NewKeyValueToken

func NewKeyValueToken(key string, value *TreeNode) *KeyValueToken

func (*KeyValueToken) String

func (this *KeyValueToken) String() string

type LRFuncToken

type LRFuncToken struct {
	EmptyToken
	Name string
}

func NewLRFuncToken

func NewLRFuncToken(name string) *LRFuncToken

func (*LRFuncToken) String

func (this *LRFuncToken) String() string

type LinearMap

type LinearMap struct {
	// contains filtered or unexported fields
}

LinearMap insure the map is iterated in the same order as the key values was added to the map.

func (*LinearMap) Get

func (this *LinearMap) Get(key string) interface{}

func (*LinearMap) Keys

func (this *LinearMap) Keys() []string

Keys returns the map keys in the same order the keys was added to the map.

func (*LinearMap) Set

func (this *LinearMap) Set(key string, value interface{})

type NumberToken

type NumberToken struct {
	EmptyToken
	Value float64
}

func NewNumberToken

func NewNumberToken(value string) *NumberToken

func (*NumberToken) String

func (this *NumberToken) String() string

type OperatorPrecedence

type OperatorPrecedence [][]string

func (OperatorPrecedence) All

func (this OperatorPrecedence) All() []string

func (OperatorPrecedence) Level

func (this OperatorPrecedence) Level(operator string) int

type OperatorToken

type OperatorToken struct {
	EmptyToken
	Operator string
	// contains filtered or unexported fields
}

func NewOperatorToken

func NewOperatorToken(operator string) *OperatorToken

func (*OperatorToken) Precedence

func (this *OperatorToken) Precedence(operator string) int

OperatorPrecedence return true if the operator argument is lower than the current operator.

func (*OperatorToken) SetOperator

func (this *OperatorToken) SetOperator(operator string)

func (*OperatorToken) String

func (this *OperatorToken) String() string

type ParseResult

type ParseResult struct {
	Root    *TreeNode
	Err     error
	Log     []string
	Mixins  map[string]*TreeNode
	Blocks  map[string]*TreeNode
	Extends string
}

func Parse

func Parse(input string) *ParseResult

type Template

type Template struct {
	Name   string
	File   []byte
	Root   *ParseResult
	IsJade bool
}

type TemplateLoader

type TemplateLoader interface {
	SetViewPath(string)
	Load(string) *Template
}

type TextToken

type TextToken struct {
	EmptyToken
	Text string
}

func NewTextToken

func NewTextToken(text string) *TextToken

func (*TextToken) String

func (this *TextToken) String() string

type Token

type Token interface {
	Category() TokenCategory
	SetError(err error)
	Error() error
	String() string
}

type TokenCategory

type TokenCategory int
const (
	CatOther TokenCategory = iota
	CatFunction
	CatValue
)

type TreeNode

type TreeNode struct {
	Value Token

	Pos int
	// contains filtered or unexported fields
}

func NewTreeNode

func NewTreeNode(value Token) *TreeNode

NewTreeElement Creates a new TreeElement.

func ParseExpression

func ParseExpression(input string) (*TreeNode, error)

func (*TreeNode) AddElement

func (this *TreeNode) AddElement(element *TreeNode) *TreeNode

Add adds a TreeElement to the end of the children items of the current node.

func (*TreeNode) Depth

func (this *TreeNode) Depth() int

func (*TreeNode) Items

func (this *TreeNode) Items() []*TreeNode

func (*TreeNode) Last

func (this *TreeNode) Last() Token

func (*TreeNode) LastElement

func (this *TreeNode) LastElement() *TreeNode

func (*TreeNode) Parent

func (this *TreeNode) Parent() *TreeNode

Parent Returns the current element parent

func (*TreeNode) PushElement

func (this *TreeNode) PushElement(element *TreeNode) *TreeNode

Push, removes the current element from its current parent, place the new value in its place and add the current element to the new element. there by pushing the current element down the hierachy. Example: tree: A(B) B.Push(C) tree: A(C(B))

func (*TreeNode) ReplaceNode

func (this *TreeNode) ReplaceNode(node *TreeNode) *TreeNode

func (*TreeNode) Root

func (this *TreeNode) Root() *TreeNode

func (*TreeNode) String

func (this *TreeNode) String() string

func (*TreeNode) StringContent

func (this *TreeNode) StringContent() string

type VariableNotDefined

type VariableNotDefined struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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