Versions in this module Expand all Collapse all v0 v0.2.546 Jan 29, 2024 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 + Write func(w io.Writer, indent int) error + type BoolConstantAttribute struct + Name string + func (bca BoolConstantAttribute) String() string + func (bca BoolConstantAttribute) Write(w io.Writer, indent int) error + type BoolExpressionAttribute struct + Expression Expression + Name string + func (ea BoolExpressionAttribute) String() string + func (ea BoolExpressionAttribute) Write(w io.Writer, indent int) error + type CSSProperty interface + IsCSSProperty func() bool + Write func(w io.Writer, indent int) error + type CSSTemplate struct + Name Expression + Properties []CSSProperty + func (css CSSTemplate) IsTemplateFileNode() bool + func (css CSSTemplate) Write(w io.Writer, indent int) error + type CallTemplateExpression struct + Expression Expression + func (cte CallTemplateExpression) IsNode() bool + func (cte CallTemplateExpression) Write(w io.Writer, indent int) error + type CaseExpression struct + Children []Node + Diagnostics []Diagnostic + Expression Expression + type ChildrenExpression struct + func (ChildrenExpression) IsNode() bool + func (ChildrenExpression) Write(w io.Writer, indent int) error + type ConditionalAttribute struct + Else []Attribute + Expression Expression + Then []Attribute + func (ca ConditionalAttribute) String() string + func (ca ConditionalAttribute) Write(w io.Writer, indent int) error + type ConstantAttribute struct + Name string + SingleQuote bool + Value string + func (ca ConstantAttribute) String() string + func (ca ConstantAttribute) Write(w io.Writer, indent int) error + type ConstantCSSProperty struct + Name string + Value string + func (c ConstantCSSProperty) IsCSSProperty() bool + func (c ConstantCSSProperty) String(minified bool) string + func (c ConstantCSSProperty) Write(w io.Writer, indent int) error + type Diagnostic struct + Message string + Range Range + type DocType struct + Value string + func (dt DocType) IsNode() bool + func (dt DocType) Write(w io.Writer, indent int) error + type Element struct + Attributes []Attribute + Children []Node + Diagnostics []Diagnostic + IndentAttrs bool + IndentChildren bool + Name string + TrailingSpace TrailingSpace + func (e Element) IsBlockElement() bool + func (e Element) IsNode() bool + func (e Element) IsVoidElement() bool + func (e Element) Trailing() TrailingSpace + func (e Element) Validate() (msgs []string, ok bool) + func (e Element) Write(w io.Writer, indent int) error + type ElseIfExpression struct + Diagnostics []Diagnostic + Expression Expression + Then []Node + type Expression struct + Range Range + Value string + func NewExpression(value string, from, to parse.Position) Expression + type ExpressionAttribute struct + Expression Expression + Name string + func (ea ExpressionAttribute) String() string + func (ea ExpressionAttribute) Write(w io.Writer, indent int) (err error) + type ExpressionCSSProperty struct + Name string + Value StringExpression + func (c ExpressionCSSProperty) IsCSSProperty() bool + func (c ExpressionCSSProperty) Write(w io.Writer, indent int) error + type ForExpression struct + Children []Node + Diagnostics []Diagnostic + Expression Expression + func (fe ForExpression) IsNode() bool + func (fe ForExpression) Write(w io.Writer, indent int) error + type GoComment struct + Contents string + Multiline bool + func (c GoComment) IsNode() bool + func (c GoComment) Write(w io.Writer, indent int) error + type HTMLComment struct + Contents string + func (c HTMLComment) IsNode() bool + func (c HTMLComment) Write(w io.Writer, indent int) error + type HTMLTemplate struct + Children []Node + Diagnostics []Diagnostic + Expression Expression + func (t HTMLTemplate) IsTemplateFileNode() bool + func (t HTMLTemplate) Write(w io.Writer, indent int) error + type IfExpression struct + Diagnostics []Diagnostic + Else []Node + ElseIfs []ElseIfExpression + Expression Expression + Then []Node + func (n IfExpression) IsNode() bool + func (n IfExpression) Write(w io.Writer, indent int) error + type Node interface + IsNode func() bool + Write func(w io.Writer, indent int) error + type Nodes struct + Diagnostics []Diagnostic + Nodes []Node + type Package struct + Expression Expression + 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 + type RawElement struct + Attributes []Attribute + Contents string + Name string + func (e RawElement) IsNode() bool + func (e RawElement) Write(w io.Writer, indent int) error + type ScriptTemplate struct + Name Expression + Parameters Expression + Value string + func (s ScriptTemplate) IsTemplateFileNode() bool + func (s ScriptTemplate) Write(w io.Writer, indent int) error + type SourceMap struct + SourceLinesToTarget map[uint32]map[uint32]Position + TargetLinesToSource map[uint32]map[uint32]Position + func NewSourceMap() *SourceMap + func (sm *SourceMap) Add(src Expression, tgt Range) (updatedFrom Position) + func (sm *SourceMap) SourcePositionFromTarget(line, col uint32) (src Position, ok bool) + func (sm *SourceMap) TargetPositionFromSource(line, col uint32) (tgt Position, ok bool) + type SpreadAttributes struct + Expression Expression + func (sa SpreadAttributes) String() string + func (sa SpreadAttributes) Write(w io.Writer, indent int) error + type StringExpression struct + Expression Expression + TrailingSpace TrailingSpace + func (se StringExpression) IsNode() bool + func (se StringExpression) IsStyleDeclarationValue() bool + func (se StringExpression) Trailing() TrailingSpace + func (se StringExpression) Write(w io.Writer, indent int) error + type SwitchExpression struct + Cases []CaseExpression + Expression Expression + func (se SwitchExpression) IsNode() bool + func (se SwitchExpression) Write(w io.Writer, indent int) error + type TemplElementExpression struct + Children []Node + Diagnostics []Diagnostic + Expression Expression + func (tee TemplElementExpression) IsNode() bool + func (tee TemplElementExpression) Write(w io.Writer, indent int) error + type TemplateFile struct + Diagnostics []Diagnostic + Header []TemplateFileGoExpression + Nodes []TemplateFileNode + Package Package + func Parse(fileName string) (TemplateFile, error) + func ParseString(template string) (TemplateFile, error) + func (tf TemplateFile) Write(w io.Writer) error + type TemplateFileGoExpression struct + Expression Expression + func (exp TemplateFileGoExpression) IsTemplateFileNode() bool + func (exp TemplateFileGoExpression) Write(w io.Writer, indent int) error + type TemplateFileNode interface + IsTemplateFileNode func() bool + 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, ok bool, err error) + type Text struct + TrailingSpace TrailingSpace + Value string + func (t Text) IsNode() bool + func (t Text) Trailing() TrailingSpace + func (t Text) Write(w io.Writer, indent int) error + type TrailingSpace string + const SpaceHorizontal + const SpaceNone + const SpaceVertical + func NewTrailingSpace(s string) (ts TrailingSpace, err error) + type Whitespace struct + Value string + func (ws Whitespace) IsNode() bool + func (ws Whitespace) Write(w io.Writer, indent int) error + type WhitespaceTrailer interface + Trailing func() TrailingSpace