Documentation
¶
Index ¶
- type MediaQuery
- type NodeContext
- type RenderInterface
- type Renderer
- type Resolver
- type Stack
- func (s *Stack) All() map[string]string
- func (s *Stack) Any() map[string]any
- func (s *Stack) Depth() int
- func (s *Stack) Get(name string) (string, bool)
- func (s *Stack) GetGlobal(name string) (string, bool)
- func (s *Stack) Pop()
- func (s *Stack) Push()
- func (s *Stack) Set(name, value string)
- func (s *Stack) SetGlobal(name, value string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MediaQuery ¶
type MediaQuery struct {
Condition string // The @media condition (e.g., "(max-width: 600px)")
ParentSelName string // The parent selector context
Children []dst.Node // The declarations within the media query
Depth int // The nesting depth
}
MediaQuery represents an @media block with its selector context
type NodeContext ¶
type NodeContext struct {
Buf *strings.Builder
Node dst.Node
Stack *Stack
// SelNames should update by depth, for the root:
// [a, b, p] ; with &.active; [a.active, b.active, p.active].
// any more nested block nodes. If we kept
// a parent Block (and a chain of parents), then
// [a, b, p] + [&.active] should produce the resulting
// css tree in a simple loop:
//
// result := []*Node
// for _, v := range node.Names() {
// for _, j := range node.Children() {
// for _, y := range j.Names() {
// ctx := NodeContext{
// Depth: parentCtx.Depth+1,
// SelName: selector(v, y),
// }
// err := x.renderNode(ctx, j) // eventually render block
// if err != nil { // bubble up errors
// }
// result = append(result, r)
// }
// }
// }
SelName string
BaseDir string // Base directory for resolving relative file paths
}
func (*NodeContext) Depth ¶
func (n *NodeContext) Depth() int
type RenderInterface ¶
type RenderInterface interface {
Eval(nodes []dst.Node) []NodeContext
Render(nodes []NodeContext) []byte
}
RenderInterface separates the responsibility to render the syntax tree into two steps. In the `Eval` step, the nested structures are traversed and then produce dst.Nodes with flattened CSS. The Render function is thus much more simpler, as it doesn't have to consider depth, but just prints a series of flattened *dst.Node values.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer converts a DST into CSS output
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves variables and expressions in declarations for rendering
func NewResolver ¶
NewResolver creates a new resolver from a file's variable stack
func (*Resolver) InterpolateVariables ¶
InterpolateVariables replaces @{varname} patterns with their values from the stack This handles LESS variable interpolation syntax like .@{prefix} and @{prop}: value
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents a variable scope stack for managing variable lifetimes
func (*Stack) All ¶
All returns all variables visible in the current scope (including parent scopes)