Documentation
¶
Overview ¶
Package view parses and renders the first subset of view {} markup.
Index ¶
- func ActionFormFields(source string) (map[string][]string, error)
- func ActionFormSchema(source string) (map[string][]ActionFormField, error)
- func Canonical(source string) (string, error)
- func ComponentReferences(source string) ([]string, error)
- func DOMEventSymbols() map[string]clientlang.ValueType
- func IslandExpressionFields(expr string) []string
- func IslandRefStatement(expr string) (string, bool)
- func ParamReferences(source string) ([]string, error)
- func RenderSPA(source string) (string, error)
- func RenderWithComponents(source string, components map[string]Component) (string, error)
- func RenderWithData(source string, components map[string]Component, data map[string]string) (string, error)
- func RenderWithOptions(source string, components map[string]Component, data map[string]string, ...) (string, error)
- func ValidateClassToggleExpressionTyped(name, expr string, symbols map[string]clientlang.ValueType) error
- func ValidateIslandBoolExpression(expr string, fields map[string]bool) error
- func ValidateIslandBoolExpressionTyped(expr string, symbols map[string]clientlang.ValueType) error
- func ValidateIslandClientStatementTyped(expr string, writeSymbols map[string]clientlang.ValueType, ...) error
- func ValidateIslandClientStatementTypedWithEvents(expr string, writeSymbols map[string]clientlang.ValueType, ...) error
- func ValidateIslandClientStatementTypedWithFunctions(expr string, writeSymbols map[string]clientlang.ValueType, ...) error
- func ValidateIslandClientStatementsTyped(statements []string, writeSymbols map[string]clientlang.ValueType, ...) (map[string]bool, error)
- func ValidateIslandClientStatementsTypedWithEvents(statements []string, writeSymbols map[string]clientlang.ValueType, ...) (map[string]bool, error)
- func ValidateIslandClientStatementsTypedWithFunctions(statements []string, writeSymbols map[string]clientlang.ValueType, ...) (map[string]bool, error)
- func ValidateIslandClientStatementsTypedWithOptions(statements []string, writeSymbols map[string]clientlang.ValueType, ...) (map[string]bool, error)
- func ValidateIslandEventExpression(expr string, fields map[string]bool, handlers ...map[string]clientlang.Handler) error
- func ValidateIslandEventExpressionTyped(expr string, readSymbols map[string]clientlang.ValueType, ...) error
- func ValidateIslandEventExpressionTypedWithEvents(expr string, readSymbols map[string]clientlang.ValueType, ...) error
- func ValidateIslandEventExpressionTypedWithFunctions(expr string, readSymbols map[string]clientlang.ValueType, ...) error
- func ValidateIslandStateStatement(expr string, writeFields map[string]bool, readFields map[string]bool) error
- func ValidateIslandStateStatementTyped(expr string, writeSymbols map[string]clientlang.ValueType, ...) error
- func ValidateIslandStateStatementTypedWithFunctions(expr string, writeSymbols map[string]clientlang.ValueType, ...) error
- func ValidateReactiveAttrExpressionTyped(name, expr string, symbols map[string]clientlang.ValueType) error
- func ValidateStyleBindingExpressionTyped(name, expr string, symbols map[string]clientlang.ValueType) error
- type ActionFormField
- type Attr
- type CommandReference
- type Component
- type ComponentCall
- type ComponentCallUsage
- type ComponentIslandUsage
- type ContractReference
- type ContractReferenceKind
- type Dependencies
- type Element
- type EventDirective
- type ForDirective
- type InlineScript
- type Node
- type Options
- type QueryReference
- type StatementValidationError
- type Text
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionFormFields ¶
ActionFormFields returns direct literal 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 literal 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 ComponentReferences ¶
ComponentReferences returns unique component names directly referenced by a view markup fragment.
func DOMEventSymbols ¶ added in v0.1.5
func DOMEventSymbols() map[string]clientlang.ValueType
DOMEventSymbols returns the compiler-owned scalar DOM event scope exposed to g:on:* expressions.
func IslandExpressionFields ¶
IslandExpressionFields returns field references in a supported island event expression.
func IslandRefStatement ¶
IslandRefStatement reports whether expr is a safe DOM ref method call.
func ParamReferences ¶
func RenderSPA ¶ added in v0.1.5
RenderSPA renders a view markup fragment with escaped text and attrs.
func RenderWithComponents ¶
RenderWithComponents renders a view markup fragment with component support.
func RenderWithData ¶
func RenderWithData(source string, components map[string]Component, data map[string]string) (string, error)
RenderWithData renders a view 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 view markup fragment with component support, interpolation data, and page-scoped action endpoints.
func ValidateClassToggleExpressionTyped ¶
func ValidateClassToggleExpressionTyped(name, expr string, symbols map[string]clientlang.ValueType) error
ValidateClassToggleExpressionTyped validates a class:name directive expression.
func ValidateIslandBoolExpression ¶
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
RequiredMessage string
MinLength int
MinLengthMessage string
MaxLength int
MaxLengthMessage string
Pattern string
PatternMessage string
}
ActionFormField describes one direct literal form field for a g:post action.
type CommandReference ¶ added in v0.1.5
CommandReference records one form-local backend command intent.
func CommandReferences ¶ added in v0.1.5
func CommandReferences(source string) ([]CommandReference, error)
CommandReferences returns package-qualified command references declared by g:command on direct form elements in a view fragment.
type Component ¶
type Component struct {
Name string
Package string
Uses map[string]string
JS []string
InlineJS []InlineScript
ScopeIDs []string
DefaultIsland 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 literal component template known to the view renderer.
type ComponentCall ¶
ComponentCall invokes a parsed component with literal string props.
type ComponentCallUsage ¶
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 ¶
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 ContractReference ¶ added in v0.1.5
type ContractReference struct {
Kind ContractReferenceKind
Name string
Method string
Path string
Start int
End int
}
ContractReference records one template-local backend contract intent.
func ContractReferences ¶ added in v0.1.5
func ContractReferences(source string) ([]ContractReference, error)
ContractReferences returns package-qualified command and query references declared by GOWDK view directives.
type ContractReferenceKind ¶ added in v0.1.5
type ContractReferenceKind string
const ( ContractReferenceCommand ContractReferenceKind = "command" ContractReferenceQuery ContractReferenceKind = "query" )
type Dependencies ¶
Dependencies records source dependencies visible in the first view subset.
func ViewDependencies ¶
func ViewDependencies(source string) (Dependencies, error)
ViewDependencies returns direct literal asset and style references from a view markup fragment. Interpolated and external URLs are not reported.
type Element ¶
func (Element) SPAAttrInterpolated ¶ added in v0.1.5
func (Element) SPAInputType ¶ added in v0.1.5
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 ¶
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 InlineScript ¶ added in v0.2.3
InlineScript records browser module code declared directly inside a component source file.
type QueryReference ¶ added in v0.1.5
QueryReference records one template-local backend query intent.
func QueryReferences ¶ added in v0.1.5
func QueryReferences(source string) ([]QueryReference, error)
QueryReferences returns package-qualified query references declared by g:query on direct HTML elements in a view fragment.
type StatementValidationError ¶
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
Source Files
¶
- action_form_controls.go
- action_forms.go
- api.go
- bindings.go
- canonical.go
- component.go
- component_references.go
- conditional.go
- contract_references.go
- dependencies.go
- element.go
- events.go
- helpers.go
- interpolate.go
- island_helpers.go
- island_statements.go
- island_validation.go
- node_loop.go
- output.go
- param_collect.go
- param_references.go
- parser.go
- patterns.go
- render.go
- render_context.go
- view.go