package goexpression
import "github.com/a-h/templ/parser/v2/goexpression"
Index ¶
- Variables
- func Case(content string) (start, end int, err error)
- func Expression(src string) (start, end int, err error)
- func For(content string) (start, end int, err error)
- func Func(content string) (name, expr string, err error)
- func If(content string) (start, end int, err error)
- func SliceArgs(content string) (expr string, err error)
- func Switch(content string) (start, end int, err error)
- func TemplExpression(src string) (start, end int, err error)
- type ErrUnbalanced
- type ExpressionParser
- func NewExpressionParser() *ExpressionParser
- func (ep *ExpressionParser) Insert( pos token.Pos, tok token.Token, lit string, ) (stop bool, err error)
- type Extractor
- type Stack
Variables ¶
var ( ErrContainerFuncNotFound = errors.New("parser error: templ container function not found") ErrExpectedNodeNotFound = errors.New("parser error: expected node not found") )
Functions ¶
func Case ¶
func Expression ¶
func For ¶
func Func ¶
Func returns the Go code up to the opening brace of the function body.
func If ¶
func SliceArgs ¶
func Switch ¶
func TemplExpression ¶
Types ¶
type ErrUnbalanced ¶
func (ErrUnbalanced) Error ¶
func (e ErrUnbalanced) Error() string
type ExpressionParser ¶
type ExpressionParser struct { Stack Stack[token.Token] End int Previous token.Token Fns Stack[int] // Stack of function depths. }
func NewExpressionParser ¶
func NewExpressionParser() *ExpressionParser
func (*ExpressionParser) Insert ¶
func (ep *ExpressionParser) Insert( pos token.Pos, tok token.Token, lit string, ) (stop bool, err error)
type Extractor ¶
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 ¶
type Stack[T any] []T
func (*Stack[T]) Peek ¶
func (s *Stack[T]) Peek() (v T)
func (*Stack[T]) Pop ¶
func (s *Stack[T]) Pop() (v T)
func (*Stack[T]) Push ¶
func (s *Stack[T]) Push(v T)
Source Files ¶
- Version
- v0.3.906 (latest)
- Published
- Jun 25, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 2 weeks ago –
Tools for package owners.