Versions in this module Expand all Collapse all v0 v0.5.0 Jul 17, 2026 v0.4.0 Jul 17, 2026 Changes in this version + var ErrLegacyFileFormat = errors.New("legacy file format - run templ migrate") + var ErrNonSpaceCharacter = errors.New("non space character found") + var ErrTemplateNotFound = errors.New("template not found") + func ExpressionOf(p parse.Parser[string]) parse.Parser[Expression] + func StripType[T any](p parse.Parser[T]) parse.Parser[any] + type Attribute interface + Copy func() Attribute + Visit func(v Visitor) error + Write func(w io.Writer, indent int) error + func CopyAttributes(attrs []Attribute) (copies []Attribute) + type AttributeComment struct + Comment string + Multiline bool + Range Range + func (ac *AttributeComment) Copy() Attribute + func (ac *AttributeComment) String() string + func (ac *AttributeComment) Visit(v Visitor) error + func (ac *AttributeComment) Write(w io.Writer, indent int) error + type AttributeKey interface + type BoolConstantAttribute struct + Key AttributeKey + Range Range + func (bca *BoolConstantAttribute) Copy() Attribute + func (bca *BoolConstantAttribute) String() string + func (bca *BoolConstantAttribute) Visit(v Visitor) error + func (bca *BoolConstantAttribute) Write(w io.Writer, indent int) error + type BoolExpressionAttribute struct + Expression Expression + Key AttributeKey + Range Range + func (bea *BoolExpressionAttribute) Copy() Attribute + func (bea *BoolExpressionAttribute) String() string + func (bea *BoolExpressionAttribute) Visit(v Visitor) error + func (bea *BoolExpressionAttribute) Write(w io.Writer, indent int) error + type CSSProperty interface + IsCSSProperty func() bool + Visit func(v Visitor) error + Write func(w io.Writer, indent int) error + type CSSTemplate struct + Expression Expression + Name string + Properties []CSSProperty + Range Range + func (css *CSSTemplate) IsTemplateFileNode() bool + func (css *CSSTemplate) Visit(v Visitor) error + func (css *CSSTemplate) Write(w io.Writer, indent int) error + type CallTemplateExpression struct + Expression Expression + Range Range + func (cte *CallTemplateExpression) IsNode() bool + func (cte *CallTemplateExpression) Visit(v Visitor) error + func (cte *CallTemplateExpression) Write(w io.Writer, indent int) error + type CaseExpression struct + Children []Node + Expression Expression + type ChildrenExpression struct + Range Range + func (*ChildrenExpression) IsNode() bool + func (*ChildrenExpression) Write(w io.Writer, indent int) error + func (ce *ChildrenExpression) Visit(v Visitor) error + type CompositeNode interface + ChildNodes func() []Node + type ConditionalAttribute struct + Else []Attribute + Expression Expression + Range Range + Then []Attribute + func (ca *ConditionalAttribute) Copy() Attribute + func (ca *ConditionalAttribute) String() string + func (ca *ConditionalAttribute) Visit(v Visitor) error + func (ca *ConditionalAttribute) Write(w io.Writer, indent int) error + type ConstantAttribute struct + Key AttributeKey + Range Range + SingleQuote bool + Value string + ValueRange Range + func (ca *ConstantAttribute) Copy() Attribute + func (ca *ConstantAttribute) String() string + func (ca *ConstantAttribute) Visit(v Visitor) error + func (ca *ConstantAttribute) Write(w io.Writer, indent int) error + type ConstantAttributeKey struct + Name string + NameRange Range + func (c ConstantAttributeKey) String() string + type ConstantCSSProperty struct + Name string + Value string + func (c *ConstantCSSProperty) IsCSSProperty() bool + func (c *ConstantCSSProperty) Visit(v Visitor) error + func (c *ConstantCSSProperty) Write(w io.Writer, indent int) error + func (c ConstantCSSProperty) String(minified bool) string + type Diagnostic struct + Message string + Range Range + func Diagnose(t *TemplateFile) ([]Diagnostic, error) + type DocType struct + CloseRange Range + OpenRange Range + Range Range + Value string + ValueRange Range + func (dt *DocType) IsNode() bool + func (dt *DocType) Visit(v Visitor) error + func (dt *DocType) Write(w io.Writer, indent int) error + type Element struct + Attributes []Attribute + Children []Node + CloseTagRange *Range + IndentAttrs bool + IndentChildren bool + Name string + NameRange Range + OpenTagRange Range + Range Range + SelfClosing bool + TrailingSpace TrailingSpace + func (e *Element) IsNode() bool + func (e *Element) Visit(v Visitor) error + func (e *Element) Write(w io.Writer, indent int) error + func (e Element) ChildNodes() []Node + func (e Element) IsBlockElement() bool + func (e Element) IsVoidElement() bool + func (e Element) Trailing() TrailingSpace + func (e Element) Validate() (msgs []string, ok bool) + type ElseIfExpression struct + Expression Expression + Range Range + Then []Node + type Expression struct + Range Range + Value string + func NewExpression(value string, from, to parse.Position) Expression + type ExpressionAttribute struct + AttributeStartRange Range + Expression Expression + Key AttributeKey + Range Range + func (ea *ExpressionAttribute) Copy() Attribute + func (ea *ExpressionAttribute) String() string + func (ea *ExpressionAttribute) Visit(v Visitor) error + func (ea *ExpressionAttribute) Write(w io.Writer, indent int) (err error) + type ExpressionAttributeKey struct + Expression Expression + func (e ExpressionAttributeKey) String() string + type ExpressionCSSProperty struct + Name string + Value *StringExpression + func (c *ExpressionCSSProperty) IsCSSProperty() bool + func (c *ExpressionCSSProperty) Visit(v Visitor) error + func (c *ExpressionCSSProperty) Write(w io.Writer, indent int) error + type Fallthrough struct + Range Range + func (f *Fallthrough) IsNode() bool + func (f *Fallthrough) Visit(v Visitor) error + func (f *Fallthrough) Write(w io.Writer, indent int) error + type ForExpression struct + Children []Node + Expression Expression + Range Range + func (fe *ForExpression) IsNode() bool + func (fe *ForExpression) Visit(v Visitor) error + func (fe *ForExpression) Write(w io.Writer, indent int) error + func (fe ForExpression) ChildNodes() []Node + type GoCode struct + Expression Expression + Multiline bool + Range Range + TrailingSpace TrailingSpace + func (gc *GoCode) IsNode() bool + func (gc *GoCode) Trailing() TrailingSpace + func (gc *GoCode) Visit(v Visitor) error + func (gc *GoCode) Write(w io.Writer, indent int) error + type GoComment struct + Contents string + Multiline bool + Range Range + func (c *GoComment) IsNode() bool + func (c *GoComment) Visit(v Visitor) error + func (c *GoComment) Write(w io.Writer, indent int) error + type HTMLComment struct + Contents string + Range Range + func (c *HTMLComment) IsNode() bool + func (c *HTMLComment) Visit(v Visitor) error + func (c *HTMLComment) Write(w io.Writer, indent int) error + type HTMLTemplate struct + Children []Node + Expression Expression + Range Range + func (t *HTMLTemplate) IsTemplateFileNode() bool + func (t *HTMLTemplate) Visit(v Visitor) error + func (t *HTMLTemplate) Write(w io.Writer, indent int) error + type IfExpression struct + Else []Node + ElseIfs []ElseIfExpression + Expression Expression + Range Range + Then []Node + func (n *IfExpression) IsNode() bool + func (n *IfExpression) Visit(v Visitor) error + func (n *IfExpression) Write(w io.Writer, indent int) error + func (n IfExpression) ChildNodes() []Node + type Node interface + IsNode func() bool + Visit func(v Visitor) error + Write func(w io.Writer, indent int) error + type Nodes struct + Nodes []Node + type Package struct + Expression Expression + func (p *Package) Visit(v Visitor) error + func (p *Package) Write(w io.Writer, indent int) error + type Position struct + Col uint32 + Index int64 + Line uint32 + func NewPosition(index int64, line, col uint32) Position + func (p *Position) String() string + type Range struct + From Position + To Position + func NewRange(from, to parse.Position) Range + type RawElement struct + Attributes []Attribute + CloseTagRange Range + Contents string + Name string + NameRange Range + OpenTagRange Range + Range Range + func (e *RawElement) IsNode() bool + func (e *RawElement) Visit(v Visitor) error + func (e *RawElement) Write(w io.Writer, indent int) error + type ScriptContents struct + GoCode *GoCode + InsideStringLiteral bool + Value *string + func NewScriptContentsGo(code *GoCode, insideStringLiteral bool) ScriptContents + func NewScriptContentsScriptCode(value string) ScriptContents + type ScriptElement struct + Attributes []Attribute + CloseTagRange Range + Contents []ScriptContents + OpenTagRange Range + Range Range + func (se *ScriptElement) IsNode() bool + func (se *ScriptElement) Visit(v Visitor) error + func (se *ScriptElement) Write(w io.Writer, indent int) error + type ScriptTemplate struct + Name Expression + Parameters Expression + Range Range + Value string + func (s *ScriptTemplate) IsTemplateFileNode() bool + func (s *ScriptTemplate) Visit(v Visitor) error + func (s *ScriptTemplate) Write(w io.Writer, indent int) error + type SourceMap struct + Expressions []string + SourceLinesToTarget map[uint32]map[uint32]Position + SourceSymbolRangeToTarget map[uint32]map[uint32]Range + TargetLinesToSource map[uint32]map[uint32]Position + TargetSymbolRangeToSource map[uint32]map[uint32]Range + func NewSourceMap() *SourceMap + func (sm *SourceMap) Add(src Expression, tgt Range) (updatedFrom Position) + func (sm *SourceMap) AddSymbolRange(src Range, tgt Range) + func (sm *SourceMap) SourcePositionFromTarget(line, col uint32) (src Position, ok bool) + func (sm *SourceMap) SymbolSourceRangeFromTarget(line, col uint32) (src Range, ok bool) + func (sm *SourceMap) SymbolTargetRangeFromSource(line, col uint32) (tgt Range, ok bool) + func (sm *SourceMap) TargetPositionFromSource(line, col uint32) (tgt Position, ok bool) + type SpreadAttributes struct + Expression Expression + Range Range + func (sa *SpreadAttributes) Copy() Attribute + func (sa *SpreadAttributes) String() string + func (sa *SpreadAttributes) Visit(v Visitor) error + func (sa *SpreadAttributes) Write(w io.Writer, indent int) error + type StringExpression struct + Expression Expression + Range Range + TrailingSpace TrailingSpace + func (se *StringExpression) IsNode() bool + func (se *StringExpression) IsStyleDeclarationValue() bool + func (se *StringExpression) Trailing() TrailingSpace + func (se *StringExpression) Visit(v Visitor) error + func (se *StringExpression) Write(w io.Writer, indent int) error + type SwitchExpression struct + Cases []CaseExpression + Expression Expression + Range Range + func (se *SwitchExpression) IsNode() bool + func (se *SwitchExpression) Visit(v Visitor) error + func (se *SwitchExpression) Write(w io.Writer, indent int) error + func (se SwitchExpression) ChildNodes() []Node + type TemplElementExpression struct + Children []Node + Expression Expression + Range Range + TrailingSpace TrailingSpace + func (tee *TemplElementExpression) IsNode() bool + func (tee *TemplElementExpression) Visit(v Visitor) error + func (tee *TemplElementExpression) Write(w io.Writer, indent int) error + func (tee TemplElementExpression) ChildNodes() []Node + func (tee TemplElementExpression) Trailing() TrailingSpace + type TemplateFile struct + Filepath string + Header []*TemplateFileGoExpression + Nodes []TemplateFileNode + Package Package + func Parse(fileName string) (*TemplateFile, error) + func ParseString(template string) (*TemplateFile, error) + func (tf *TemplateFile) Visit(v Visitor) error + func (tf *TemplateFile) Write(w io.Writer) error + type TemplateFileGoExpression struct + BeforePackage bool + Expression Expression + func (exp *TemplateFileGoExpression) IsTemplateFileNode() bool + func (exp *TemplateFileGoExpression) Visit(v Visitor) error + func (exp *TemplateFileGoExpression) Write(w io.Writer, indent int) error + type TemplateFileNode interface + IsTemplateFileNode func() bool + Visit func(v Visitor) error + Write func(w io.Writer, indent int) error + type TemplateFileParser struct + DefaultPackage string + func NewTemplateFileParser(pkg string) TemplateFileParser + func (p TemplateFileParser) Parse(pi *parse.Input) (tf *TemplateFile, matched bool, err error) + type Text struct + Range Range + TrailingSpace TrailingSpace + Value string + func (t *Text) IsNode() bool + func (t *Text) Visit(v Visitor) error + func (t *Text) Write(w io.Writer, indent int) error + func (t Text) Trailing() TrailingSpace + type TrailingSpace string + const SpaceHorizontal + const SpaceNone + const SpaceVertical + func NewTrailingSpace(s string) (ts TrailingSpace, err error) + type UntilNotFoundError struct + type Visitor interface + VisitBoolConstantAttribute func(*BoolConstantAttribute) error + VisitBoolExpressionAttribute func(*BoolExpressionAttribute) error + VisitCSSTemplate func(*CSSTemplate) error + VisitCallTemplateExpression func(*CallTemplateExpression) error + VisitChildrenExpression func(*ChildrenExpression) error + VisitConditionalAttribute func(*ConditionalAttribute) error + VisitConstantAttribute func(*ConstantAttribute) error + VisitConstantCSSProperty func(*ConstantCSSProperty) error + VisitDocType func(*DocType) error + VisitElement func(*Element) error + VisitExpressionAttribute func(*ExpressionAttribute) error + VisitExpressionCSSProperty func(*ExpressionCSSProperty) error + VisitFallthrough func(*Fallthrough) error + VisitForExpression func(*ForExpression) error + VisitGoCode func(*GoCode) error + VisitGoComment func(*GoComment) error + VisitHTMLComment func(*HTMLComment) error + VisitHTMLTemplate func(*HTMLTemplate) error + VisitIfExpression func(*IfExpression) error + VisitPackage func(*Package) error + VisitRawElement func(*RawElement) error + VisitScriptElement func(*ScriptElement) error + VisitScriptTemplate func(*ScriptTemplate) error + VisitSpreadAttributes func(*SpreadAttributes) error + VisitStringExpression func(*StringExpression) error + VisitSwitchExpression func(*SwitchExpression) error + VisitTemplElementExpression func(*TemplElementExpression) error + VisitTemplateFile func(*TemplateFile) error + VisitTemplateFileGoExpression func(*TemplateFileGoExpression) error + VisitText func(*Text) error + VisitWhitespace func(*Whitespace) error + type Whitespace struct + Range Range + Value string + func (ws *Whitespace) IsNode() bool + func (ws *Whitespace) Visit(v Visitor) error + func (ws *Whitespace) Write(w io.Writer, indent int) error + type WhitespaceTrailer interface + Trailing func() TrailingSpace