Documentation
¶
Overview ¶
Package sfc provides a parser for GoSPA Single File Components (.gospa).
Index ¶
- func OffsetToPosition(input string, offset int) (int, int)
- type Attribute
- type BaseNode
- type Block
- type CommentNode
- type ComponentNode
- type DiagnosticError
- type EachNode
- type ElementNode
- type ElseIfNode
- type ExpressionNode
- type IfNode
- type Node
- type NodeType
- type SFC
- type SnippetNode
- type TemplateParser
- type TextNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attribute ¶ added in v0.1.32
type Attribute struct {
Name string
Value string
IsExpression bool // If the value is a {expression}
}
Attribute represents an HTML attribute.
type BaseNode ¶ added in v0.1.32
BaseNode contains common fields for all nodes.
type Block ¶
type Block struct {
Type string // "script", "template", "style"
Lang string // e.g., "go", "ts", "css"
Content string
ByteOffset int // Start of the content block in the original source
Line int // 0-indexed line number
Column int // 0-indexed column number
}
Block represents a section of a .gospa file.
type CommentNode ¶ added in v0.1.32
CommentNode represents an HTML comment.
type ComponentNode ¶ added in v0.1.32
ComponentNode represents a component call (@Component).
type DiagnosticError ¶ added in v0.1.39
DiagnosticError is a structured compile diagnostic with exact source location and optional remediation guidance.
func (*DiagnosticError) Error ¶ added in v0.1.39
func (e *DiagnosticError) Error() string
Error implements error.
type ElementNode ¶ added in v0.1.32
type ElementNode struct {
BaseNode
TagName string
Attributes []Attribute
Children []Node
SelfClosing bool
}
ElementNode represents an HTML element.
type ElseIfNode ¶ added in v0.1.32
ElseIfNode represents an {:else if} block.
type ExpressionNode ¶ added in v0.1.32
ExpressionNode represents a {expression}.
type IfNode ¶ added in v0.1.32
type IfNode struct {
BaseNode
Condition string
Then []Node
ElseIfs []ElseIfNode
Else []Node
}
IfNode represents a {#if} block.
type SFC ¶
type SFC struct {
FrontMatter map[string]string
Script Block
ScriptTS Block
Template Block
Style Block
}
SFC represents the parsed structure of a .gospa file.
type SnippetNode ¶ added in v0.1.32
SnippetNode represents a {#snippet} definition.
type TemplateParser ¶ added in v0.1.32
type TemplateParser struct {
// contains filtered or unexported fields
}
TemplateParser parses a GoSPA template string into an AST.
func NewTemplateParser ¶ added in v0.1.32
func NewTemplateParser(input string, offset int, line, col int) *TemplateParser
NewTemplateParser creates a new TemplateParser.
func (*TemplateParser) Parse ¶ added in v0.1.32
func (p *TemplateParser) Parse() ([]Node, error)
Parse returns the root list of nodes.