Documentation
¶
Index ¶
- func SetIndentConfig(config IndentConfig)
- func TraverseNode(n NodeList, f func(*ElementNode))
- type Attribute
- type AttributeEntityEncodingFromTo
- type CommentNode
- type ConfiguredNodeList
- type ElementNode
- type IndentConfig
- type Node
- type NodeList
- type ParentNode
- type Parser
- type RawNode
- type TemplateExpressionNode
- type TwigBlockNode
- type TwigIfNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetIndentConfig ¶
func SetIndentConfig(config IndentConfig)
SetIndentConfig updates the global indentation configuration.
func TraverseNode ¶
func TraverseNode(n NodeList, f func(*ElementNode))
Types ¶
type CommentNode ¶
CommentNode represents an HTML comment.
func (*CommentNode) Dump ¶
func (c *CommentNode) Dump(indent int) string
Dump returns the comment text with HTML comment syntax.
type ConfiguredNodeList ¶
type ConfiguredNodeList struct {
Nodes NodeList
Config IndentConfig
}
ConfiguredNodeList wraps a NodeList with its associated IndentConfig
func NewAdminParser ¶
func NewAdminParser(input string) (ConfiguredNodeList, error)
NewAdminParser creates a parser configured for admin twig files (no indentation for twig block children).
func NewFrontendParser ¶ added in v0.0.3
func NewFrontendParser(input string) (ConfiguredNodeList, error)
NewFrontendParser creates a parser configured for frontend twig files (indents twig block children).
func (ConfiguredNodeList) Dump ¶
func (cnl ConfiguredNodeList) Dump(indent int) string
Dump renders the nodes using the stored configuration
type ElementNode ¶
type ElementNode struct {
Tag string
Attributes NodeList
Children NodeList
SelfClosing bool
Line int // added field
}
ElementNode represents an HTML element.
func (*ElementNode) Dump ¶
func (e *ElementNode) Dump(indent int) string
Dump returns the HTML representation of the element and its children.
type IndentConfig ¶
IndentConfig holds configuration for indentation in HTML output.
func DefaultIndentConfig ¶
func DefaultIndentConfig() IndentConfig
DefaultIndentConfig creates a default indentation config with spaces.
func (IndentConfig) GetIndent ¶
func (c IndentConfig) GetIndent() string
GetIndent returns the indentation string based on configuration.
type NodeList ¶
type NodeList []Node
func NewParserWithConfig ¶
func NewParserWithConfig(input string, config IndentConfig) (NodeList, error)
NewParserWithConfig creates a new parser with a specific indentation configuration.
type ParentNode ¶
type ParentNode struct {
Line int
}
ParentNode represents a twig parent() call
func (*ParentNode) Dump ¶
func (p *ParentNode) Dump(indent int) string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser holds the state for our simple parser.
type TemplateExpressionNode ¶
TemplateExpressionNode represents a {{...}} template expression.
func (*TemplateExpressionNode) Dump ¶
func (t *TemplateExpressionNode) Dump(indent int) string
Dump returns the template expression with {{ }} delimiters.
type TwigBlockNode ¶
TwigBlockNode represents a twig block.
func (*TwigBlockNode) Dump ¶
func (t *TwigBlockNode) Dump(indent int) string
Dump returns the twig block with proper formatting.
type TwigIfNode ¶
type TwigIfNode struct {
Condition string
Children NodeList
ElseIfConditions []string
ElseIfChildren []NodeList
ElseChildren NodeList
Line int
}
TwigIfNode represents a Twig if block
func (*TwigIfNode) Dump ¶
func (t *TwigIfNode) Dump(indent int) string
Dump returns the twig if block with proper formatting