view

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package view parses and renders the first static subset of view {} markup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionFormFields

func ActionFormFields(source string) (map[string][]string, error)

ActionFormFields returns direct static HTML control names grouped by g:post action name. Component-hidden controls are intentionally not inferred in this first decoder slice.

func ActionFormSchema

func ActionFormSchema(source string) (map[string][]ActionFormField, error)

ActionFormSchema returns direct static HTML controls grouped by g:post action name. Duplicate field names are merged, and Required is true if any matching direct control is required.

func Canonical

func Canonical(source string) (string, error)

Canonical returns a deterministic AST-backed representation of a view body.

func ComponentReferences

func ComponentReferences(source string) ([]string, error)

ComponentReferences returns unique component names directly referenced by a static markup fragment.

func IslandExpressionFields

func IslandExpressionFields(expr string) []string

IslandExpressionFields returns field references in a supported island event expression.

func IslandRefStatement

func IslandRefStatement(expr string) (string, bool)

IslandRefStatement reports whether expr is a safe DOM ref method call.

func ParamReferences

func ParamReferences(source string) ([]string, error)

ParamReferences returns unique param("name") route-param references directly visible in the current static markup subset.

func RenderStatic

func RenderStatic(source string) (string, error)

RenderStatic renders a static markup fragment with escaped text and attrs.

func RenderWithComponents

func RenderWithComponents(source string, components map[string]Component) (string, error)

RenderWithComponents renders a static markup fragment with component support.

func RenderWithData

func RenderWithData(source string, components map[string]Component, data map[string]string) (string, error)

RenderWithData renders a static markup fragment with component support and string interpolation data.

func RenderWithOptions

func RenderWithOptions(source string, components map[string]Component, data map[string]string, options Options) (string, error)

RenderWithOptions renders a static markup fragment with component support, interpolation data, and page-scoped action routes.

func ValidateClassToggleExpressionTyped

func ValidateClassToggleExpressionTyped(name, expr string, symbols map[string]clientlang.ValueType) error

ValidateClassToggleExpressionTyped validates a class:name directive expression.

func ValidateIslandBoolExpression

func ValidateIslandBoolExpression(expr string, fields map[string]bool) error

ValidateIslandBoolExpression validates a g:if-style bool expression.

func ValidateIslandBoolExpressionTyped

func ValidateIslandBoolExpressionTyped(expr string, symbols map[string]clientlang.ValueType) error

ValidateIslandBoolExpressionTyped validates a g:if-style bool expression with scalar type information.

func ValidateIslandClientStatementTyped

func ValidateIslandClientStatementTyped(expr string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType, refs map[string]clientlang.Ref) error

ValidateIslandClientStatementTyped validates a client statement that may mutate state or call a safe DOM ref method.

func ValidateIslandClientStatementTypedWithEvents

func ValidateIslandClientStatementTypedWithEvents(expr string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType, refs map[string]clientlang.Ref, helpers map[string]clientlang.ExprFunction, emits map[string]clientlang.Emit) error

ValidateIslandClientStatementTypedWithEvents validates a client statement that may mutate state, call a safe DOM ref method, read helper functions, or dispatch declared component events.

func ValidateIslandClientStatementTypedWithFunctions

func ValidateIslandClientStatementTypedWithFunctions(expr string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType, refs map[string]clientlang.Ref, helpers map[string]clientlang.ExprFunction) error

ValidateIslandClientStatementTypedWithFunctions validates a client statement that may mutate state, call a safe DOM ref method, or read helper functions.

func ValidateIslandClientStatementsTyped

func ValidateIslandClientStatementsTyped(statements []string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType, refs map[string]clientlang.Ref) (map[string]bool, error)

ValidateIslandClientStatementsTyped validates an ordered client statement block. Local variables declared with let are visible only to later statements in the same block.

func ValidateIslandClientStatementsTypedWithEvents

func ValidateIslandClientStatementsTypedWithEvents(statements []string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType, refs map[string]clientlang.Ref, helpers map[string]clientlang.ExprFunction, async bool, emits map[string]clientlang.Emit) (map[string]bool, error)

ValidateIslandClientStatementsTypedWithEvents validates an ordered client statement block with optional component event dispatch support.

func ValidateIslandClientStatementsTypedWithFunctions

func ValidateIslandClientStatementsTypedWithFunctions(statements []string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType, refs map[string]clientlang.Ref, helpers map[string]clientlang.ExprFunction) (map[string]bool, error)

ValidateIslandClientStatementsTypedWithFunctions validates an ordered client statement block. Local variables declared with let are visible only to later statements in the same block.

func ValidateIslandClientStatementsTypedWithOptions

func ValidateIslandClientStatementsTypedWithOptions(statements []string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType, refs map[string]clientlang.Ref, helpers map[string]clientlang.ExprFunction, async bool) (map[string]bool, error)

ValidateIslandClientStatementsTypedWithOptions validates an ordered client statement block with the same local-variable rules as ValidateIslandClientStatementsTypedWithFunctions. Async blocks may use compiler-owned await expressions.

func ValidateIslandEventExpression

func ValidateIslandEventExpression(expr string, fields map[string]bool, handlers ...map[string]clientlang.Handler) error

ValidateIslandEventExpression validates the first generated-JS event expression subset. When fields is non-nil, every referenced field must exist. Named client function calls are valid only when handlers declares that function.

func ValidateIslandEventExpressionTyped

func ValidateIslandEventExpressionTyped(expr string, readSymbols map[string]clientlang.ValueType, writeSymbols map[string]clientlang.ValueType, handlers map[string]clientlang.Handler) error

ValidateIslandEventExpressionTyped validates an event expression with scalar type information.

func ValidateIslandEventExpressionTypedWithEvents

func ValidateIslandEventExpressionTypedWithEvents(expr string, readSymbols map[string]clientlang.ValueType, writeSymbols map[string]clientlang.ValueType, handlers map[string]clientlang.Handler, helpers map[string]clientlang.ExprFunction, emits map[string]clientlang.Emit) error

ValidateIslandEventExpressionTypedWithEvents validates an event expression, including component event dispatch statements.

func ValidateIslandEventExpressionTypedWithFunctions

func ValidateIslandEventExpressionTypedWithFunctions(expr string, readSymbols map[string]clientlang.ValueType, writeSymbols map[string]clientlang.ValueType, handlers map[string]clientlang.Handler, helpers map[string]clientlang.ExprFunction) error

ValidateIslandEventExpressionTypedWithFunctions validates an event expression with scalar type information and return-valued helper functions.

func ValidateIslandStateStatement

func ValidateIslandStateStatement(expr string, writeFields map[string]bool, readFields map[string]bool) error

ValidateIslandStateStatement validates a client statement that may write only writeFields and may read readFields plus scalar literals.

func ValidateIslandStateStatementTyped

func ValidateIslandStateStatementTyped(expr string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType) error

ValidateIslandStateStatementTyped validates a state statement with scalar type information.

func ValidateIslandStateStatementTypedWithFunctions

func ValidateIslandStateStatementTypedWithFunctions(expr string, writeSymbols map[string]clientlang.ValueType, readSymbols map[string]clientlang.ValueType, helpers map[string]clientlang.ExprFunction) error

ValidateIslandStateStatementTypedWithFunctions validates a state statement with scalar type information and return-valued helper functions.

func ValidateReactiveAttrExpressionTyped

func ValidateReactiveAttrExpressionTyped(name, expr string, symbols map[string]clientlang.ValueType) error

ValidateReactiveAttrExpressionTyped validates a first-slice reactive attribute expression.

func ValidateStyleBindingExpressionTyped

func ValidateStyleBindingExpressionTyped(name, expr string, symbols map[string]clientlang.ValueType) error

ValidateStyleBindingExpressionTyped validates a style:name directive expression.

Types

type ActionFormField

type ActionFormField struct {
	Name     string
	Required bool
}

ActionFormField describes one direct static form field for a g:post action.

type Attr

type Attr struct {
	Name       string
	Value      string
	Boolean    bool
	Expression bool
}

Attr is a static HTML attribute.

type Component

type Component struct {
	Name         string
	Props        []string
	State        map[string]string
	StateJSON    string
	Handlers     map[string]clientlang.Handler
	HandlersJSON string
	StateTypes   map[string]clientlang.ValueType
	Refs         map[string]clientlang.Ref
	Emits        map[string]clientlang.Emit
	Computed     []clientlang.Computed
	Body         string
}

Component is a static component template known to the view renderer.

func (Component) HasProp

func (component Component) HasProp(name string) bool

HasProp reports whether a component declares a prop.

type ComponentCall

type ComponentCall struct {
	Name     string
	Attrs    []Attr
	Children []Node
}

ComponentCall invokes a parsed component with static string props.

type ComponentCallUsage

type ComponentCallUsage struct {
	Component     string
	Island        string
	ReactiveProps bool
}

ComponentCallUsage records one component call and its optional island mode.

func ComponentCallUsages

func ComponentCallUsages(source string) ([]ComponentCallUsage, error)

ComponentCallUsages returns component calls with optional g:island metadata.

type ComponentIslandUsage

type ComponentIslandUsage struct {
	Component string
	Mode      string
}

ComponentIslandUsage records one component call that explicitly selects an island runtime.

func ComponentIslandUsages

func ComponentIslandUsages(source string) ([]ComponentIslandUsage, error)

ComponentIslandUsages returns component calls that explicitly set g:island.

type Dependencies

type Dependencies struct {
	StaticAssets    []string
	CSSClasses      []string
	StyleAttributes []string
}

Dependencies records static dependencies visible in the first view subset.

func ViewDependencies

func ViewDependencies(source string) (Dependencies, error)

ViewDependencies returns direct static asset and style references from a static markup fragment. Interpolated and external URLs are not reported.

type Element

type Element struct {
	Name     string
	Attrs    []Attr
	Children []Node
}

Element is a lowercase HTML element.

type EventDirective

type EventDirective struct {
	Event      string
	Prevent    bool
	Stop       bool
	Once       bool
	Capture    bool
	DebounceMS int
	ThrottleMS int
}

EventDirective is a parsed g:on:<event>[.<modifier>] directive.

func ParseEventDirective

func ParseEventDirective(name string) (EventDirective, error)

ParseEventDirective validates and splits a g:on directive name.

func (EventDirective) RuntimeOptions

func (directive EventDirective) RuntimeOptions() string

RuntimeOptions returns the compact modifier string emitted into HTML.

type ForDirective

type ForDirective struct {
	Var        string
	IndexVar   string
	Collection string
}

ForDirective is a parsed g:for declaration.

func ParseForDirective

func ParseForDirective(source string) (ForDirective, error)

ParseForDirective parses a g:for value such as "item in Items" or "item, i in Items".

type Node

type Node interface {
	// contains filtered or unexported methods
}

Node is a static view markup node.

func Parse

func Parse(source string) ([]Node, error)

Parse parses a static markup fragment.

type Options

type Options struct {
	Actions map[string]string
}

Options configures static view rendering.

type StatementValidationError

type StatementValidationError struct {
	Index int
	Err   error
}

StatementValidationError identifies the statement index that failed within a client statement block.

func (StatementValidationError) Error

func (err StatementValidationError) Error() string

func (StatementValidationError) Unwrap

func (err StatementValidationError) Unwrap() error

type Text

type Text struct {
	Value string
}

Text is escaped text content.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL