Documentation
¶
Index ¶
- Variables
- func Case(content []byte) (start, end int, err error)
- func Expression(src []byte) (start, end int, err error)
- func For(content []byte) (start, end int, err error)
- func Func(content []byte) (name, expr string, err error)
- func If(content []byte) (start, end int, err error)
- func SliceArgs(content []byte) (expr string, err error)
- func Switch(content []byte) (start, end int, err error)
- func TemplExpression(src []byte) (start, end int, err error)
- type ErrUnbalanced
- type ExpressionParser
- type Extractor
- type Stack
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Expression ¶
func Func ¶
Func returns the Go code up to the opening brace of the function body. The content starts after the "func " keyword.
When the signature parses with an empty body, only the signature is parsed, not the templ code that follows it. When the signature has a syntax error, the whole of content is parsed and the error is ignored, so that the Go compiler reports it against the generated code, which maps back to its position in the templ file.
func SliceArgs ¶
SliceArgs returns the Go code up to the closing brace of a templ expression.
When the arguments parse, only the code up to the closing brace is parsed, not the templ code that follows it. When the arguments have a syntax error, the whole of content is parsed and the error is ignored, so that the Go compiler reports it against the generated code.
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