goexpression

package
v0.2.663 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContainerFuncNotFound = errors.New("parser error: templ container function not found")
	ErrExpectedNodeNotFound  = errors.New("parser error: expected node not found")
)

Functions

func Case

func Case(content string) (start, end int, err error)

func Expression

func Expression(src string) (start, end int, err error)

func For

func For(content string) (start, end int, err error)

func Func

func Func(content string) (name, expr string, err error)

Func returns the Go code up to the opening brace of the function body.

func If

func If(content string) (start, end int, err error)

func SliceArgs

func SliceArgs(content string) (expr string, err error)

func Switch

func Switch(content string) (start, end int, err error)

func TemplExpression added in v0.2.619

func TemplExpression(src string) (start, end int, err error)

Types

type ErrUnbalanced added in v0.2.619

type ErrUnbalanced struct {
	Token token.Token
}

func (ErrUnbalanced) Error added in v0.2.619

func (e ErrUnbalanced) Error() string

type ExpressionParser added in v0.2.619

type ExpressionParser struct {
	Stack    Stack[token.Token]
	End      int
	Previous token.Token
	Fns      Stack[int] // Stack of function depths.
	Slices   Stack[int] // Stack of slice depths.
}

func NewExpressionParser added in v0.2.619

func NewExpressionParser() *ExpressionParser

func (*ExpressionParser) Insert added in v0.2.619

func (ep *ExpressionParser) Insert(pos token.Pos, tok token.Token, lit string) (stop bool, err error)

type Extractor

type Extractor func(body []ast.Stmt) (start, end int, err error)

Extract a Go expression from the content. The Go expression starts at "start" and ends at "end". The reader should skip until "length" to pass over the expression and into the next logical block.

type Stack added in v0.2.619

type Stack[T any] []T

func (*Stack[T]) Peek added in v0.2.619

func (s *Stack[T]) Peek() (v T)

func (*Stack[T]) Pop added in v0.2.619

func (s *Stack[T]) Pop() (v T)

func (*Stack[T]) Push added in v0.2.619

func (s *Stack[T]) Push(v T)

Jump to

Keyboard shortcuts

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